Skip to content

Commit

Permalink
Fix async usage of test functions
Browse files Browse the repository at this point in the history
  • Loading branch information
scorbajio committed Sep 26, 2024
1 parent a742276 commit 4896ef1
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions packages/trie/test/trie/checkpoint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ describe('testing checkpoints', () => {
},
]

async function trieEval(trie: Trie, value: any) {
const trieEval = async (trie: Trie, value: any) => {
const actualValue = await trie.get(key)
const pass = actualValue === null ? value === null : equalsBytes(actualValue, value)
return pass
Expand All @@ -345,28 +345,28 @@ describe('testing checkpoints', () => {
const trie = new Trie()

await trie.put(key, kv.v1)
await trie.flushCheckpoints()
trie.flushCheckpoints()

assert.ok(await trieEval(trie, kv.v1))
})
it('CP -> V1 -> Commit -> Flush() (-> V1)', async () => {
const trie = new Trie()

await trie.checkpoint()
trie.checkpoint()
await trie.put(key, kv.v1)
await trie.commit()
await trie.flushCheckpoints()
trie.flushCheckpoints()

assert.ok(await trieEval(trie, kv.v1))
})

it('CP -> V1 -> Revert -> Flush() (-> Undefined)', async () => {
const trie = new Trie()

await trie.checkpoint()
trie.checkpoint()
await trie.put(key, kv.v1)
await trie.revert()
await trie.flushCheckpoints()
trie.flushCheckpoints()

assert.ok(await trieEval(trie, null))
})
Expand All @@ -375,9 +375,9 @@ describe('testing checkpoints', () => {
const trie = new Trie()

await trie.put(key, kv.v1)
await trie.checkpoint()
trie.checkpoint()
await trie.commit()
await trie.flushCheckpoints()
trie.flushCheckpoints()

assert.ok(await trieEval(trie, kv.v1))
})
Expand All @@ -386,9 +386,9 @@ describe('testing checkpoints', () => {
const trie = new Trie()

await trie.put(key, kv.v1)
await trie.checkpoint()
trie.checkpoint()
await trie.revert()
await trie.flushCheckpoints()
trie.flushCheckpoints()

assert.ok(await trieEval(trie, kv.v1))
})
Expand All @@ -397,10 +397,10 @@ describe('testing checkpoints', () => {
const trie = new Trie()

await trie.put(key, kv.v1)
await trie.checkpoint()
trie.checkpoint()
await trie.put(key, kv.v2)
await trie.commit()
await trie.flushCheckpoints()
trie.flushCheckpoints()

assert.ok(await trieEval(trie, kv.v2))
})
Expand All @@ -409,11 +409,11 @@ describe('testing checkpoints', () => {
const trie = new Trie()

await trie.put(key, kv.v1)
await trie.checkpoint()
trie.checkpoint()
await trie.put(key, kv.v2)
await trie.commit()
await trie.put(key, kv.v3)
await trie.flushCheckpoints()
trie.flushCheckpoints()

assert.ok(await trieEval(trie, kv.v3))
})
Expand All @@ -422,36 +422,36 @@ describe('testing checkpoints', () => {
const trie = new Trie()

await trie.put(key, kv.v1)
await trie.checkpoint()
trie.checkpoint()
await trie.put(key, kv.v2)
await trie.put(key, kv.v3)
await trie.commit()
await trie.flushCheckpoints()
trie.flushCheckpoints()

assert.ok(await trieEval(trie, kv.v3))
})

it('CP -> V1 -> V2 -> Commit -> Flush() (-> V2)', async () => {
const trie = new Trie()

await trie.checkpoint()
trie.checkpoint()
await trie.put(key, kv.v1)
await trie.put(key, kv.v2)
await trie.commit()
await trie.flushCheckpoints()
trie.flushCheckpoints()

assert.ok(await trieEval(trie, kv.v2))
})

it('CP -> V1 -> V2 -> Revert -> Flush() (-> Undefined)', async () => {
const trie = new Trie()

await trie.checkpoint()
trie.checkpoint()
await trie.put(key, kv.v1)

await trie.put(key, kv.v2)
await trie.revert()
await trie.flushCheckpoints()
trie.flushCheckpoints()

assert.ok(await trieEval(trie, null))
})
Expand All @@ -460,10 +460,10 @@ describe('testing checkpoints', () => {
const trie = new Trie()

await trie.put(key, kv.v1)
await trie.checkpoint()
trie.checkpoint()
await trie.put(key, kv.v2)
await trie.revert()
await trie.flushCheckpoints()
trie.flushCheckpoints()

assert.ok(await trieEval(trie, kv.v1))
})
Expand All @@ -472,13 +472,13 @@ describe('testing checkpoints', () => {
const trie = new Trie()

await trie.put(key, kv.v1)
await trie.checkpoint()
trie.checkpoint()
await trie.put(key, kv.v2)
await trie.checkpoint()
trie.checkpoint()
await trie.put(key, kv.v3)
await trie.commit()
await trie.commit()
await trie.flushCheckpoints()
trie.flushCheckpoints()

assert.ok(await trieEval(trie, kv.v3))
})
Expand All @@ -487,13 +487,13 @@ describe('testing checkpoints', () => {
const trie = new Trie()

await trie.put(key, kv.v1)
await trie.checkpoint()
trie.checkpoint()
await trie.put(key, kv.v2)
await trie.checkpoint()
trie.checkpoint()
await trie.put(key, kv.v3)
await trie.commit()
await trie.revert()
await trie.flushCheckpoints()
trie.flushCheckpoints()

assert.ok(await trieEval(trie, kv.v1))
})
Expand All @@ -502,13 +502,13 @@ describe('testing checkpoints', () => {
const trie = new Trie()

await trie.put(key, kv.v1)
await trie.checkpoint()
trie.checkpoint()
await trie.put(key, kv.v2)
await trie.checkpoint()
trie.checkpoint()
await trie.put(key, kv.v3)
await trie.revert()
await trie.commit()
await trie.flushCheckpoints()
trie.flushCheckpoints()

assert.ok(await trieEval(trie, kv.v2))
})
Expand All @@ -517,14 +517,14 @@ describe('testing checkpoints', () => {
const trie = new Trie()

await trie.put(key, kv.v1)
await trie.checkpoint()
trie.checkpoint()
await trie.put(key, kv.v2)
await trie.checkpoint()
trie.checkpoint()
await trie.put(key, kv.v3)
await trie.revert()
await trie.put(key, kv.v4)
await trie.commit()
await trie.flushCheckpoints()
trie.flushCheckpoints()

assert.ok(await trieEval(trie, kv.v4))
})
Expand All @@ -533,17 +533,17 @@ describe('testing checkpoints', () => {
const trie = new Trie()

await trie.put(key, kv.v1)
await trie.checkpoint()
trie.checkpoint()
await trie.put(key, kv.v2)
await trie.checkpoint()
trie.checkpoint()
await trie.put(key, kv.v3)
await trie.revert()
await trie.put(key, kv.v4)
await trie.checkpoint()
trie.checkpoint()
await trie.put(key, kv.v5)
await trie.commit()
await trie.commit()
await trie.flushCheckpoints()
trie.flushCheckpoints()

assert.ok(await trieEval(trie, kv.v5))
})
Expand Down

0 comments on commit 4896ef1

Please sign in to comment.