pub(crate) fn do_read_write_remove_list_persist<K: KVStore + RefUnwindSafe>(kv_store: &K) {
let data = [42u8; 32];
- let namespace = "testspace";
- let sub_namespace = "testsubspace";
+ let primary_namespace = "testspace";
+ let secondary_namespace = "testsubspace";
let key = "testkey";
// Test the basic KVStore operations.
- kv_store.write(namespace, sub_namespace, key, &data).unwrap();
+ kv_store.write(primary_namespace, secondary_namespace, key, &data).unwrap();
- // Test empty namespace/sub_namespace is allowed, but not empty namespace and non-empty
- // sub-namespace, and not empty key.
+ // Test empty primary_namespace/secondary_namespace is allowed, but not empty primary_namespace
+ // and non-empty secondary_namespace, and not empty key.
kv_store.write("", "", key, &data).unwrap();
- let res = std::panic::catch_unwind(|| kv_store.write("", sub_namespace, key, &data));
+ let res = std::panic::catch_unwind(|| kv_store.write("", secondary_namespace, key, &data));
assert!(res.is_err());
- let res = std::panic::catch_unwind(|| kv_store.write(namespace, sub_namespace, "", &data));
+ let res = std::panic::catch_unwind(|| kv_store.write(primary_namespace, secondary_namespace, "", &data));
assert!(res.is_err());
- let listed_keys = kv_store.list(namespace, sub_namespace).unwrap();
+ let listed_keys = kv_store.list(primary_namespace, secondary_namespace).unwrap();
assert_eq!(listed_keys.len(), 1);
assert_eq!(listed_keys[0], key);
- let read_data = kv_store.read(namespace, sub_namespace, key).unwrap();
+ let read_data = kv_store.read(primary_namespace, secondary_namespace, key).unwrap();
assert_eq!(data, &*read_data);
- kv_store.remove(namespace, sub_namespace, key, false).unwrap();
+ kv_store.remove(primary_namespace, secondary_namespace, key, false).unwrap();
- let listed_keys = kv_store.list(namespace, sub_namespace).unwrap();
+ let listed_keys = kv_store.list(primary_namespace, secondary_namespace).unwrap();
assert_eq!(listed_keys.len(), 0);
- // Ensure we have no issue operating with namespace/sub_namespace/key being KVSTORE_NAMESPACE_KEY_MAX_LEN
+ // Ensure we have no issue operating with primary_namespace/secondary_namespace/key being
+ // KVSTORE_NAMESPACE_KEY_MAX_LEN
let max_chars: String = std::iter::repeat('A').take(KVSTORE_NAMESPACE_KEY_MAX_LEN).collect();
kv_store.write(&max_chars, &max_chars, &max_chars, &data).unwrap();
// Force close because cooperative close doesn't result in any persisted
// updates.
- nodes[0].node.force_close_broadcasting_latest_txn(&nodes[0].node.list_channels()[0].channel_id, &nodes[1].node.get_our_node_id()).unwrap();
+ let error_message = "Channel force-closed";
+ nodes[0].node.force_close_broadcasting_latest_txn(&nodes[0].node.list_channels()[0].channel_id, &nodes[1].node.get_our_node_id(), error_message.to_string()).unwrap();
check_closed_event!(nodes[0], 1, ClosureReason::HolderForceClosed, [nodes[1].node.get_our_node_id()], 100000);
check_closed_broadcast!(nodes[0], true);
check_added_monitors!(nodes[0], 1);