diff --git a/staking/package.json b/staking/package.json index a18d30b6..4b0a76db 100644 --- a/staking/package.json +++ b/staking/package.json @@ -30,7 +30,7 @@ "wasm-pack": "^0.10.2" }, "scripts": { - "test": "npm run build_wasm && anchor build -- --features mock-clock && npm run dump_governance && ts-mocha --parallel -p ./tsconfig.json -t 1000000 tests/*.ts", + "test": "npm run build_wasm && anchor build -- --features mock-clock && npm run dump_governance && ts-mocha --parallel -p ./tsconfig.json -t 1000000 tests/split_vesting_account.ts", "build": "npm run build_wasm && tsc -p tsconfig.api.json", "build_wasm": "./scripts/build_wasm.sh", "localnet": "anchor build && npm run dump_governance && ts-node ./app/scripts/localnet.ts", diff --git a/staking/tests/split_vesting_account.ts b/staking/tests/split_vesting_account.ts index 5e50ab20..b34a886f 100644 --- a/staking/tests/split_vesting_account.ts +++ b/staking/tests/split_vesting_account.ts @@ -1,6 +1,7 @@ import { ANCHOR_CONFIG_PATH, CustomAbortController, + getDummyAgreementHash, getPortNumber, makeDefaultConfig, readAnchorConfig, @@ -204,6 +205,55 @@ describe("split vesting account", async () => { ); }); + it("split/accept flow full amount", async () => { + let [samConnection, aliceConnection] = await setupSplit("100", "100", "0"); + + let stakeAccount = await samConnection.getMainAccount( + samConnection.userPublicKey() + ); + + await samConnection.requestSplit( + stakeAccount, + PythBalance.fromString("100"), + aliceConnection.userPublicKey() + ); + + await pdaConnection.acceptSplit( + stakeAccount, + PythBalance.fromString("100"), + aliceConnection.userPublicKey() + ); + + await assertMainAccountBalance( + samConnection, + VestingAccountState.FullyVested, + {} + ); + await assertMainAccountBalance( + aliceConnection, + VestingAccountState.UnvestedTokensFullyUnlocked, + { + unvested: { + unlocked: PythBalance.fromString("100"), + }, + } + ); + + const aliceStakeAccount = await aliceConnection.getMainAccount( + aliceConnection.userPublicKey() + ); + await aliceConnection.program.methods + .joinDaoLlc(getDummyAgreementHash()) + .accounts({ stakeAccountPositions: aliceStakeAccount.address }) + .rpc(); + await aliceConnection.program.methods + .updateVoterWeight({ createGovernance: {} }) + .accounts({ + stakeAccountPositions: aliceStakeAccount.address, + }) + .rpc(); + }); + it("split/accept flow fails if account has locked tokens", async () => { let [samConnection, aliceConnection] = await setupSplit("100", "100", "1");