generated from hirosystems/.github
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: re-org issue with cycle-signer-set data (#53)
- Loading branch information
Showing
2 changed files
with
64 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import * as fs from 'node:fs'; | ||
import { PgStore } from '../../src/pg/pg-store'; | ||
import { RpcStackerSetResponse } from '../../src/stacks-core-rpc/stacks-core-rpc-client'; | ||
import { rpcStackerSetToDbRewardSetSigners } from '../../src/stacks-core-rpc/stacker-set-updater'; | ||
|
||
describe('Duplicate signer set insert', () => { | ||
let db: PgStore; | ||
|
||
beforeAll(async () => { | ||
db = await PgStore.connect(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await db.close(); | ||
}); | ||
|
||
test('Insert initial signer set', async () => { | ||
const stackerSetDump = JSON.parse( | ||
fs.readFileSync('./tests/dumps/dump-stacker-set-cycle-72-2024-11-02.json', 'utf8') | ||
) as RpcStackerSetResponse; | ||
const insertResult = await db.chainhook.insertRewardSetSigners( | ||
db.sql, | ||
rpcStackerSetToDbRewardSetSigners(stackerSetDump, 72) | ||
); | ||
expect(insertResult).toEqual({ | ||
rowsDeleted: 0, | ||
rowsInserted: 11, | ||
}); | ||
}); | ||
|
||
test('Overwrite signer set', async () => { | ||
const stackerSetDump = JSON.parse( | ||
fs.readFileSync('./tests/dumps/dump-stacker-set-cycle-72-2024-11-02.json', 'utf8') | ||
) as RpcStackerSetResponse; | ||
const insertResult = await db.chainhook.insertRewardSetSigners( | ||
db.sql, | ||
rpcStackerSetToDbRewardSetSigners(stackerSetDump, 72) | ||
); | ||
expect(insertResult).toEqual({ | ||
rowsDeleted: 11, | ||
rowsInserted: 11, | ||
}); | ||
}); | ||
}); |