Skip to content

Commit 7c5601f

Browse files
committed
Fix tests. Apply yarn format
1 parent da52ac1 commit 7c5601f

File tree

2 files changed

+34
-21
lines changed

2 files changed

+34
-21
lines changed

solana/tests/api_test.ts

+16-4
Original file line numberDiff line numberDiff line change
@@ -987,12 +987,16 @@ describe("api", async () => {
987987
WHTokenBalance.fromString("150"),
988988
);
989989

990+
let voteStart = Math.floor(Date.now() / 1000) + 12;
990991
let proposalIdInput = await addTestProposal(
991992
user3StakeConnection,
992-
Math.floor(Date.now() / 1000) + 12,
993+
voteStart,
993994
);
994-
await sleep(13000);
995995

996+
while (voteStart >= Math.floor(Date.now() / 1000)) {
997+
await sleep(1000);
998+
}
999+
await sleep(1000);
9961000
await user3StakeConnection.castVote(
9971001
proposalIdInput,
9981002
new BN(10),
@@ -1027,6 +1031,7 @@ describe("api", async () => {
10271031
it("should cast vote with the correct weight", async () => {
10281032
let stakeAccountCheckpointsAddress;
10291033
let proposalIdInput;
1034+
let voteStart;
10301035

10311036
// Create 6 checkpoints, 1 second apart
10321037
for (let i = 0; i < 6; i++) {
@@ -1038,15 +1043,20 @@ describe("api", async () => {
10381043
// Create a proposal with a start time 10 seconds in the future in iteration 5
10391044
// We do this because the vote weight window is 10 seconds
10401045
if (i == 4) {
1046+
voteStart = Math.floor(Date.now() / 1000) + 10;
10411047
proposalIdInput = await addTestProposal(
10421048
user7StakeConnection,
1043-
Math.floor(Date.now() / 1000) + 10,
1049+
voteStart,
10441050
);
10451051
}
10461052

10471053
await sleep(1000);
10481054
}
10491055

1056+
while (voteStart >= Math.floor(Date.now() / 1000)) {
1057+
await sleep(1000);
1058+
}
1059+
await sleep(1000);
10501060
await user7StakeConnection.castVote(
10511061
proposalIdInput,
10521062
new BN(10),
@@ -1062,7 +1072,6 @@ describe("api", async () => {
10621072
assert.equal(againstVotes.toString(), "10");
10631073
assert.equal(forVotes.toString(), "20");
10641074
assert.equal(abstainVotes.toString(), "12");
1065-
10661075
});
10671076

10681077
it("should fail to castVote if next voter checkpoints are invalid", async () => {
@@ -1090,6 +1099,9 @@ describe("api", async () => {
10901099
);
10911100
}
10921101
await sleep(5000);
1102+
while (voteStart >= Math.floor(Date.now() / 1000)) {
1103+
await sleep(1000);
1104+
}
10931105

10941106
let currentStakeAccountCheckpointsAddress =
10951107
await user4StakeConnection.getStakeAccountCheckpointsAddress(

solana/tests/vesting.ts

+18-17
Original file line numberDiff line numberDiff line change
@@ -550,11 +550,11 @@ describe("vesting", () => {
550550

551551
await stakeConnection.program.methods
552552
.initializeVestingConfig(seed2)
553-
.accounts({
554-
...accounts,
555-
config: config2,
556-
vault: vault2,
557-
})
553+
.accounts({
554+
...accounts,
555+
config: config2,
556+
vault: vault2,
557+
})
558558
.signers([whMintAuthority])
559559
.rpc()
560560
.then(confirm);
@@ -675,12 +675,12 @@ describe("vesting", () => {
675675
it("Create another matured vests", async () => {
676676
await stakeConnection.program.methods
677677
.createVesting(NOW, new BN(100e6))
678-
.accounts({
679-
...accounts,
680-
config: config2,
681-
vestingBalance: vestingBalance2,
682-
vest: vestNow2,
683-
})
678+
.accounts({
679+
...accounts,
680+
config: config2,
681+
vestingBalance: vestingBalance2,
682+
vest: vestNow2,
683+
})
684684
.signers([whMintAuthority])
685685
.rpc({
686686
skipPreflight: true,
@@ -1015,12 +1015,13 @@ describe("vesting", () => {
10151015
);
10161016

10171017
await sleep(2000);
1018-
let stakeAccountCheckpointsAddress = await vesterStakeConnection.delegateWithVest(
1019-
vesterStakeConnection.userPublicKey(),
1020-
WHTokenBalance.fromString("0"),
1021-
true,
1022-
config2,
1023-
);
1018+
let stakeAccountCheckpointsAddress =
1019+
await vesterStakeConnection.delegateWithVest(
1020+
vesterStakeConnection.userPublicKey(),
1021+
WHTokenBalance.fromString("0"),
1022+
true,
1023+
config2,
1024+
);
10241025

10251026
let stakeAccountCheckpointsData =
10261027
await vesterStakeConnection.program.account.checkpointData.fetch(

0 commit comments

Comments
 (0)