Skip to content

Commit 6e98c3c

Browse files
committed
test: add check to rosetta contract tests
1 parent 023cf79 commit 6e98c3c

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

src/tests-2.1-transition/pox-transition.ts

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -779,8 +779,37 @@ describe('PoX transition tests', () => {
779779
expect(BigInt(rosettaBalance.locked.balances[0].value)).toBe(0n);
780780
});
781781

782-
test('Stand-by for period 2a', async () => {
783-
// Assuming the following ENV from `zone117x/stacks-api-e2e:stacks2.1-transition-feat-segwit-events-8fb6fad`
782+
test('Rosetta stack-stx in Period 1 uses pox-1', async () => {
783+
// Assuming the following ENV:
784+
// STACKS_21_HEIGHT=120
785+
// STACKS_POX2_HEIGHT = 136
786+
787+
poxInfo = await client.getPox();
788+
expect(poxInfo.current_burnchain_block_height).toBeLessThan(120); // Period 1
789+
790+
ustxAmount = BigInt(Math.round(Number(poxInfo.min_amount_ustx) * 1.1).toString());
791+
792+
const rosettaStackStx = await stackStxWithRosetta({
793+
cycleCount: 1,
794+
btcAddr: account.btcAddr,
795+
stacksAddress: account.stxAddr,
796+
pubKey: account.pubKey,
797+
privateKey: account.secretKey,
798+
ustxAmount,
799+
});
800+
801+
expect(rosettaStackStx.constructionMetadata.metadata.contract_name).toBe('pox');
802+
expect(rosettaStackStx.tx.contract_call_contract_id).toBe(
803+
'ST000000000000000000002AMW42H.pox'
804+
);
805+
expect(
806+
rosettaStackStx.constructionMetadata.metadata.burn_block_height as number
807+
).toBeTruthy();
808+
expect(rosettaStackStx.submitResult.transaction_identifier.hash).toBe(rosettaStackStx.txId);
809+
});
810+
811+
test('Stand-by for Period 2a', async () => {
812+
// Assuming the following ENV:
784813
// STACKS_21_HEIGHT=120
785814
// STACKS_POX2_HEIGHT = 136
786815

@@ -795,7 +824,7 @@ describe('PoX transition tests', () => {
795824
expect(poxInfo.contract_id).toBe('ST000000000000000000002AMW42H.pox'); // pox-1 is still "active"
796825
});
797826

798-
test('Rosetta stack-stx in period 2a uses pox-2', async () => {
827+
test('Rosetta stack-stx in Period 2a uses pox-2', async () => {
799828
poxInfo = await client.getPox();
800829
ustxAmount = BigInt(Math.round(Number(poxInfo.min_amount_ustx) * 1.1).toString());
801830

@@ -818,7 +847,7 @@ describe('PoX transition tests', () => {
818847
expect(rosettaStackStx.submitResult.transaction_identifier.hash).toBe(rosettaStackStx.txId);
819848
});
820849

821-
test('Stand-by for POX2_ACTIVATION (aka the last block of period 2a)', async () => {
850+
test('Stand-by for POX2_ACTIVATION (aka the last block of Period 2a)', async () => {
822851
// POX2_ACTIVATION == poxV1UnlockHeight == v1_unlock_height
823852
poxInfo = await client.getPox();
824853
poxV1UnlockHeight = poxInfo.contract_versions![1].activation_burnchain_block_height;
@@ -836,7 +865,7 @@ describe('PoX transition tests', () => {
836865
// expect(poxInfo.contract_id).toBe('ST000000000000000000002AMW42H.pox'); // pox-1 is still "active"
837866
});
838867

839-
test('Stand-by for POX2_ACTIVATION+1 (aka first block of period 2b)', async () => {
868+
test('Stand-by for POX2_ACTIVATION+1 (aka first block of Period 2b)', async () => {
840869
await standByUntilBurnBlock(poxV1UnlockHeight + 1);
841870

842871
poxInfo = await client.getPox();
@@ -855,7 +884,7 @@ describe('PoX transition tests', () => {
855884
expect(calculatedRewardCycle + 1).toBe(poxInfo.contract_versions![1].first_reward_cycle_id);
856885
});
857886

858-
test('Stand-by for cycle N+1 (aka period 3)', async () => {
887+
test('Stand-by for cycle N+1 (aka Period 3)', async () => {
859888
const calculatedBurnHeight = rewardCycleToBurnHeight({
860889
poxInfo: poxInfo as any,
861890
rewardCycle: poxInfo.contract_versions![1].first_reward_cycle_id,

0 commit comments

Comments
 (0)