make withdraw ts tests work
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
parent
eccaecc2e5
commit
23ad57302d
|
@ -13,6 +13,7 @@ no-entrypoint = []
|
||||||
no-idl = []
|
no-idl = []
|
||||||
cpi = ["no-entrypoint"]
|
cpi = ["no-entrypoint"]
|
||||||
default = []
|
default = []
|
||||||
|
localnet = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anchor-lang = "0.18.0"
|
anchor-lang = "0.18.0"
|
||||||
|
|
|
@ -10,6 +10,11 @@ use std::convert::TryFrom;
|
||||||
vote_weight_record!(crate::ID);
|
vote_weight_record!(crate::ID);
|
||||||
|
|
||||||
/// Seconds in one day.
|
/// Seconds in one day.
|
||||||
|
/// for localnet, to make testing of vesting possible,
|
||||||
|
/// set a low value so tests can just sleep for 10s to simulate a day
|
||||||
|
#[cfg(feature = "localnet")]
|
||||||
|
pub const SECS_PER_DAY: i64 = 10;
|
||||||
|
#[cfg(not(feature = "localnet"))]
|
||||||
pub const SECS_PER_DAY: i64 = 86_400;
|
pub const SECS_PER_DAY: i64 = 86_400;
|
||||||
|
|
||||||
/// Maximum number of days one can lock for.
|
/// Maximum number of days one can lock for.
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
yarn prettier --write tests
|
||||||
|
cargo fmt
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
./run-format.sh && anchor test -- --features localnet
|
|
@ -1,7 +1,7 @@
|
||||||
import * as assert from "assert";
|
import * as assert from "assert";
|
||||||
import * as anchor from "@project-serum/anchor";
|
import * as anchor from "@project-serum/anchor";
|
||||||
import { Program } from "@project-serum/anchor";
|
import { Program } from "@project-serum/anchor";
|
||||||
import { createMintAndVault } from "@project-serum/common";
|
import { createMintAndVault, sleep } from "@project-serum/common";
|
||||||
import BN from "bn.js";
|
import BN from "bn.js";
|
||||||
import {
|
import {
|
||||||
PublicKey,
|
PublicKey,
|
||||||
|
@ -273,6 +273,7 @@ describe("voting-rights", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Withdraws cliff locked A tokens", async () => {
|
it("Withdraws cliff locked A tokens", async () => {
|
||||||
|
await sleep(10000);
|
||||||
const depositId = 0;
|
const depositId = 0;
|
||||||
const amount = new BN(10);
|
const amount = new BN(10);
|
||||||
await program.rpc.withdraw(depositId, amount, {
|
await program.rpc.withdraw(depositId, amount, {
|
||||||
|
@ -329,6 +330,34 @@ describe("voting-rights", () => {
|
||||||
assert.ok(deposit.rateIdx === 0);
|
assert.ok(deposit.rateIdx === 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("Withdraws daily locked A tokens", async () => {
|
||||||
|
await sleep(10000);
|
||||||
|
const depositId = 1;
|
||||||
|
const amount = new BN(10);
|
||||||
|
await program.rpc.withdraw(depositId, amount, {
|
||||||
|
accounts: {
|
||||||
|
registrar,
|
||||||
|
voter,
|
||||||
|
exchangeVault: exchangeVaultA,
|
||||||
|
withdrawMint: mintA,
|
||||||
|
votingToken,
|
||||||
|
votingMint: votingMintA,
|
||||||
|
destination: godA,
|
||||||
|
authority: program.provider.wallet.publicKey,
|
||||||
|
tokenProgram,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const voterAccount = await program.account.voter.fetch(voter);
|
||||||
|
const deposit = voterAccount.deposits[0];
|
||||||
|
assert.ok(deposit.isUsed);
|
||||||
|
assert.ok(deposit.amountDeposited.toNumber() === 0);
|
||||||
|
assert.ok(deposit.rateIdx === 0);
|
||||||
|
|
||||||
|
const vtAccount = await votingTokenClientA.getAccountInfo(votingToken);
|
||||||
|
assert.ok(vtAccount.amount.toNumber() === 0);
|
||||||
|
});
|
||||||
|
|
||||||
it("Updates a vote weight record", async () => {
|
it("Updates a vote weight record", async () => {
|
||||||
await program.rpc.updateVoterWeightRecord({
|
await program.rpc.updateVoterWeightRecord({
|
||||||
accounts: {
|
accounts: {
|
||||||
|
|
Loading…
Reference in New Issue