Skip to content

Commit

Permalink
Add another test with full amount
Browse files Browse the repository at this point in the history
  • Loading branch information
guibescos committed Nov 10, 2023
1 parent 44429c8 commit 0994df9
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion staking/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
50 changes: 50 additions & 0 deletions staking/tests/split_vesting_account.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
ANCHOR_CONFIG_PATH,
CustomAbortController,
getDummyAgreementHash,
getPortNumber,
makeDefaultConfig,
readAnchorConfig,
Expand Down Expand Up @@ -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");

Expand Down

0 comments on commit 0994df9

Please sign in to comment.