Skip to content

test: add regtest solo stacking #1904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 113 additions & 1 deletion src/tests/pox-tests.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as supertest from 'supertest';
import { PgSqlClient } from '@hirosystems/api-toolkit';
import { PgSqlClient, timeout } from '@hirosystems/api-toolkit';
import { ChainID } from '@stacks/common';
import { ApiServer, startApiServer } from '../api/init';
import { PgWriteStore } from '../datastore/pg-write-store';
Expand Down Expand Up @@ -141,4 +141,116 @@ describe('PoX tests', () => {
total: 1,
});
});

test('api - regtest solo stacker', async () => {
await importEventsFromTsv(
'src/tests/tsv/regtest-env-pox-4-stack-stx-in-reward-phase-S1.tsv',
'archival',
true,
true
);

// TEST CASE
// steph (STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6) stacks (using signer 029fb154a570a1645af3dd43c3c668a979b59d21a46dd717fd799b13be3b2a0dc7)

const cycles = await supertest(api.server).get(`/extended/v2/pox/cycles`);
expect(cycles.status).toBe(200);
expect(cycles.type).toBe('application/json');
expect(JSON.parse(cycles.text)).toStrictEqual({
limit: 20,
offset: 0,
results: [
{
block_height: 14,
cycle_number: 6,
index_block_hash: '0x8be3f0e3b746452309347a3f2deec2bba0b1d85642092c30262c9e07e10f3529',
total_signers: 3,
total_stacked_amount: '17501190000000000',
total_weight: 21,
},
],
total: 1,
});

const cycle = await supertest(api.server).get(`/extended/v2/pox/cycles/6`);
expect(cycle.status).toBe(200);
expect(cycle.type).toBe('application/json');
expect(JSON.parse(cycle.text)).toStrictEqual({
block_height: 14,
cycle_number: 6,
index_block_hash: '0x8be3f0e3b746452309347a3f2deec2bba0b1d85642092c30262c9e07e10f3529',
total_signers: 3,
total_stacked_amount: '17501190000000000',
total_weight: 21,
});

const signers = await supertest(api.server).get(`/extended/v2/pox/cycles/6/signers`);
expect(signers.status).toBe(200);
expect(signers.type).toBe('application/json');
expect(JSON.parse(signers.text)).toStrictEqual({
limit: 100,
offset: 0,
results: [
{
signing_key: '0x028efa20fa5706567008ebaf48f7ae891342eeb944d96392f719c505c89f84ed8d',
stacked_amount: '7500510000000000',
stacked_amount_percent: 42.857142857142854,
weight: 9,
weight_percent: 42.857142857142854,
},
{
signing_key: '0x023f19d77c842b675bd8c858e9ac8b0ca2efa566f17accf8ef9ceb5a992dc67836',
stacked_amount: '5000340000000000',
stacked_amount_percent: 28.571428571428573,
weight: 6,
weight_percent: 28.57142857142857,
},
{
// steph doubled the weight of this signer
signing_key: '0x029fb154a570a1645af3dd43c3c668a979b59d21a46dd717fd799b13be3b2a0dc7',
stacked_amount: '5000340000000000',
stacked_amount_percent: 28.571428571428573,
weight: 6,
weight_percent: 28.57142857142857,
},
],
total: 3,
});

const signer = await supertest(api.server).get(
`/extended/v2/pox/cycles/6/signers/0x029fb154a570a1645af3dd43c3c668a979b59d21a46dd717fd799b13be3b2a0dc7`
);
expect(signer.status).toBe(200);
expect(signer.type).toBe('application/json');
expect(JSON.parse(signer.text)).toStrictEqual({
signing_key: '0x029fb154a570a1645af3dd43c3c668a979b59d21a46dd717fd799b13be3b2a0dc7',
stacked_amount: '5000340000000000',
stacked_amount_percent: 28.571428571428573,
weight: 6,
weight_percent: 28.57142857142857,
});

const stackers = await supertest(api.server).get(
`/extended/v2/pox/cycles/6/signers/0x029fb154a570a1645af3dd43c3c668a979b59d21a46dd717fd799b13be3b2a0dc7/stackers`
);
expect(stackers.status).toBe(200);
expect(stackers.type).toBe('application/json');
expect(JSON.parse(stackers.text)).toStrictEqual({
limit: 100,
offset: 0,
results: [
{
pox_address: '1NQAp2ecV2zUQfz7y2hLvJTU5scnFTSACM',
stacked_amount: '2500170000000000',
stacker_address: 'ST3NBRSFKX28FQ2ZJ1MAKX58HKHSDGNV5N7R21XCP', // signer
},
{
pox_address: 'mhYeZXrSEuyf2wbJ14qZ2apG7ofMLDj9Ss',
stacked_amount: '2500170000000000',
stacker_address: 'STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6', // steph
},
],
total: 2,
});
});
});
146 changes: 146 additions & 0 deletions src/tests/tsv/regtest-env-pox-4-stack-stx-in-reward-phase-S1.tsv

Large diffs are not rendered by default.

Loading