From 269d3d807981ae679b3dec7d629beee344c3cb90 Mon Sep 17 00:00:00 2001 From: Constantin Dogaru Date: Mon, 4 Apr 2022 19:32:20 +0300 Subject: [PATCH] fix staking tests --- sputnik-staking/res/sputnik_staking.wasm | Bin 187045 -> 187118 bytes sputnik-staking/src/lib.rs | 55 +++++++++++++++++------ 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/sputnik-staking/res/sputnik_staking.wasm b/sputnik-staking/res/sputnik_staking.wasm index dd1619f36a27d5de301c034bade5e9e5ebbb8aa2..5d70522272b619d4dfaaa00b87d63e31d6373014 100755 GIT binary patch delta 16754 zcmc(F3s_ZE^Y@;0xF3*%0wNbVpj-sSJErDksR*V?7t1tX6_rdf@3-nrNHHl<(TyxL zR7ye;Ozof>jY@qf(JZOVOOcmErLv?XBc=Ri_Bs2oL4E&y&;NU#PoKluznNLHX3d&4 zYt}yJ?Y+id_8NDGIU2yv%M$4rV{psZe@HT>N<3@7WwOg;274`s+|D^cfhFJTamF$> z$iKIV@;$TlV4B3E&5YMdDLg%&5VCrEzlsu;54_KLK)od|^nGyqWG(Uf@U$#BsUv4u zS(bv16~NvB`KRy@FE-dL@op(*X8JBIElrB^kY5j<)Xvk$D_^B&DH$h< zt(&2p{A5&|{A2hH_)b0-@h)7GS4U3vELcf$S+A;cyi{(C%z-nq+-Wq_%HMYyFTW90 z1C5rn=tlvH1)Ia zH%q(H<($b_5cXuZvhY%Nz+Je@%yPt zhNP4lVheMj9KrM<@Bh(>=q&a9dj6!i-li7#c zCg!Qh->JzI`-qy;t#?wk_igIlR6rri{nxX)9&%Rq zXxaa_an?>zmaV_VH&tUOU3Vkpev0PQr(iEjb-hco9$DR~pft)IZgz!3@}XPafeT{U zZvAZZ=2({B^ieIYu8)!{{y5j%v?fhgWv@T|?`H}Ba~j#d{m){3_X)SAbzdu!cf*@| zcUmmV*V~h?^RE2stxGhkQ@1@K^@`eifYzJuRdII>Th}TZV%cEbS{<|(&dt`!nkrV2 zIqs%ow0^eia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RjYC(J{y;@3LiLc)9vs{B2j`oC!_?<^D( zA(VHJvx{*nq`O3$gZKu~J&3O2{e(R=xTq8Ukg&Uk|2g6Q8vGGqKKZJ?i-dW!Rg4r} z8d!pr;6end60A6cu+~5%cc!fBNBdQz+6YqW0osI@pigMYE|S>MAL=Y4RHc{Z0)-bgVnPhLDXdBIYW zuVNX8v1fV%vH6l)wqWj3mD@%%?sv+9W%FGI8wBz|n4g>`c+s*)Wn($c)VZx3!j%d_ z^-#0<%PdEx8$_QS71$>rX_!IqBj$4YaQ!N7AqRVNERU(cdkFK`m}7JXU1f#GaJXCV zkp`hVaUH4cL9IV)K86e3atZQ@oJb$8ELWa)9M=K1$FpDG$7tRLoWKa)K6(PjI=9Cg zgnlHqQebajhUDA9rtRD6n_xpEcXqUWg^{0BYr13~4}S+Ar# z6+08w>eF|^E@nK-s=&3AK-W%q0%0C1)j$eitpke)^D|%NFDGnvSiW--pRi9}Io2RV zlfY{F@ZGQCx9ORCs^SBkaB(MG(h0w#VpjG6Wo}i?L6yAYLmV_frSehnu&THx;RFpH zt@7Dy>IN%WJ~ip8^w-4Iy82Bg97=hEpP{OJ1YxbUq)xb!@Hmb9Wx^9Q_?nr|9yv#s zv?7*v4hK0GC7KJi_m$P;#XdMkSFR#fcaAQJMa-{?PPk#Lu?in|OB`?B5m}FzH)0kW zbDoNWN(($iEl(1OY}I)j?p#mMNU;48cIrINm^^%fK{-99Qp-2N9BO%9SWGSNmPDUF zlgTF;3XKqFB=r_Aj^{Pq)UWzT+$kxs`6^3D7y%lR0`xwR1FtI_^(gAhsWNY?Z*=}u&RpWqa!9(=&JC&eQDIFX;L)O*US} HPjvqcWPAAT diff --git a/sputnik-staking/src/lib.rs b/sputnik-staking/src/lib.rs index cf9446ac2..b02a72f1c 100644 --- a/sputnik-staking/src/lib.rs +++ b/sputnik-staking/src/lib.rs @@ -184,27 +184,54 @@ mod tests { #[test] fn test_basics() { - let period = 1000; + const UNSTAKE_PERIOD: u64 = 1000; + let contract_owner: AccountId = accounts(0); + let voting_token: AccountId = accounts(1); + let delegate_from_user: AccountId = accounts(2); + let delegate_to_user: AccountId = accounts(3); + let mut context = VMContextBuilder::new(); - testing_env!(context.predecessor_account_id(accounts(0)).build()); - let mut contract = Contract::new(accounts(0), accounts(1), U64(period)); + testing_env!(context + .predecessor_account_id(contract_owner.clone()) + .build()); + let mut contract = Contract::new(contract_owner, voting_token.clone(), U64(UNSTAKE_PERIOD)); + testing_env!(context.attached_deposit(to_yocto("1")).build()); - contract.storage_deposit(Some(accounts(2)), None); - testing_env!(context.predecessor_account_id(accounts(1)).build()); - contract.ft_on_transfer(accounts(2), U128(to_yocto("100")), "".to_string()); + contract.storage_deposit(Some(delegate_from_user.clone()), None); + + testing_env!(context.predecessor_account_id(voting_token.clone()).build()); + contract.ft_on_transfer( + delegate_from_user.clone(), + U128(to_yocto("100")), + "".to_string(), + ); assert_eq!(contract.ft_total_supply().0, to_yocto("100")); - assert_eq!(contract.ft_balance_of(accounts(2)).0, to_yocto("100")); - testing_env!(context.predecessor_account_id(accounts(2)).build()); + assert_eq!( + contract.ft_balance_of(delegate_from_user.clone()).0, + to_yocto("100") + ); + + testing_env!(context + .predecessor_account_id(delegate_from_user.clone()) + .build()); contract.withdraw(U128(to_yocto("50"))); assert_eq!(contract.ft_total_supply().0, to_yocto("50")); - assert_eq!(contract.ft_balance_of(accounts(2)).0, to_yocto("50")); - contract.delegate(accounts(3), U128(to_yocto("10"))); - let user = contract.get_user(accounts(2)); + assert_eq!( + contract.ft_balance_of(delegate_from_user.clone()).0, + to_yocto("50") + ); + + testing_env!(context.attached_deposit(to_yocto("1")).build()); + contract.storage_deposit(Some(delegate_to_user.clone()), None); + + contract.delegate(delegate_to_user.clone(), U128(to_yocto("10"))); + let user = contract.get_user(delegate_from_user.clone()); assert_eq!(user.delegated_amount(), to_yocto("10")); - contract.undelegate(accounts(3), U128(to_yocto("10"))); - let user = contract.get_user(accounts(2)); + + contract.undelegate(delegate_to_user, U128(to_yocto("10"))); + let user = contract.get_user(delegate_from_user); assert_eq!(user.delegated_amount(), 0); - assert_eq!(user.next_action_timestamp, U64(period)); + assert_eq!(user.next_action_timestamp, U64(UNSTAKE_PERIOD)); } }