-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathimport-genesis.test.ts
More file actions
61 lines (52 loc) · 2.25 KB
/
import-genesis.test.ts
File metadata and controls
61 lines (52 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { importV1TokenOfferingData } from '../../src/import-v1';
import { bitcoinToStacksAddress } from '@stacks/codec';
import { PgWriteStore } from '../../src/datastore/pg-write-store';
import { migrate } from '../utils/test-helpers';
describe('import genesis data tests', () => {
let db: PgWriteStore;
beforeEach(async () => {
await migrate('up');
db = await PgWriteStore.connect({
usageName: 'tests',
withNotifier: false,
skipMigrations: true,
});
});
afterEach(async () => {
await db?.close();
await migrate('down');
});
test('import token offering data', async () => {
const initialDbConfigState = await db.getConfigState();
expect(initialDbConfigState.token_offering_imported).toBe(false);
await importV1TokenOfferingData(db);
const newDbConfigState = await db.getConfigState();
expect(newDbConfigState.token_offering_imported).toBe(true);
const addr1 = 'SP04MFJ3RWTADV6ZWTWD68DBZ14EJSDXT50Q7TE6';
const res1 = await db.getTokenOfferingLocked(addr1, 0);
expect(res1?.result?.total_locked).toEqual('33115155552');
const addr2 = 'SM2M7XTPCJK6S5XG7JKH4SGYDY9W49ZQ962MC4XPM';
const res2 = await db.getTokenOfferingLocked(addr2, 0);
expect(res2?.result?.total_locked).toEqual('111111111108');
const addr3 = 'SM37EFPD9ZVR3YRJE7673MJ3W0T350JM1HVZVCDC3';
const res3 = await db.getTokenOfferingLocked(addr3, 0);
expect(res3?.result?.total_locked).toEqual('111111109');
const addr4 = 'SM260QHD6ZM2KKPBKZB8PFE5XWP0MHSKTD1B7BHYR';
const res4 = await db.getTokenOfferingLocked(addr4, 0);
expect(res4?.result?.total_locked).toEqual('1666666664');
});
});
describe('fast b58 to c32 address conversion', () => {
test('b58 to c32 address', () => {
const addrs = [
['112XwWYtXmVGhwKPZAijeDDxeiQzAhvyDi', 'SP04MFJ3RWTADV6ZWTWD68DBZ14EJSDXT50Q7TE6'],
['1zGLA1arpjhhrXeH8QYFXW5eJX1vARGwB', 'SP5D90E31EM8BCXSYBPFDASDFM5TGHFT4SS6B0QB'],
['31hq3ykKrVrhExuCFbhDoARMo33gEsoVaw', 'SM02ENSM1ZD4EKE6D3AB0JXTJMH7N4DPK733G27X'],
['3QuovALTyVTTvR1tBB1hrHLfAQrA61hPsZ', 'SM3ZBCHS6W603C6QJJPQFVC49QE9VQ1ZVFQY1DZX7'],
];
addrs.forEach(([b58, c32]) => {
const converted = bitcoinToStacksAddress(b58);
expect(converted).toEqual(c32);
});
});
});