paritytech/parity-db

Values do not seems to be persisted on ref-counted BTree

Closed this issue · 0 comments

Tpt commented

Here is a failing test I believe should pass:

	#[test]
	fn fuzz_test() {
		let dir = tempdir().unwrap();
		let options = Options {
			path: dir.path().to_owned(),
			columns: vec![ColumnOptions {
				ref_counted: true,
				btree_index: true,
				..ColumnOptions::default()
			}],
			sync_wal: true,
			sync_data: true,
			stats: false,
			salt: None,
		};

		let db = Db::open_or_create(&options).unwrap();
		db.commit_changes(vec![(0, Operation::Set(vec![0], vec![0]))]).unwrap();

		// The value is there before closing and opening again
		assert_eq!(db.get(0, &[0]).unwrap(), Some(vec![0]));

		// Ensures we should properly join on shutdown
		assert!(db.join_on_shutdown);

		// The value is not there anymore
		drop(db);
		let db = Db::open_read_only(&options).unwrap();
		assert_eq!(db.get(0, &[0]).unwrap(), Some(vec![0]));
	}