1+ import { ethers } from "@nomiclabs/buidler" ;
12import { expect } from "chai" ;
3+ import { MockProvider } from "ethereum-waffle" ;
24import { Wallet , utils } from "ethers" ;
35import { BytesLike } from "ethers/lib/utils" ;
46import { SinglePlayerCommit } from "../typechain/SinglePlayerCommit" ;
57
6- export function shouldManageCommitments ( wallet : Wallet , walletTo : Wallet ) : void {
8+ export function shouldManageCommitments ( provider : MockProvider ) : void {
9+ const [ contractWallet , userWallet ] = provider . getWallets ( ) ;
710
8- it ( "allows the user to deposit for staking" , async function ( ) {
9- // const _activity = "biking";
10- // const _measureIndex = await this.singlePlayerCommit.measureList(0);
11- console . log ( await walletTo . getBalance ( ) ) ;
12- const _amount = utils . parseEther ( "1.0" ) ;
13- let contractWithSigner = await this . singlePlayerCommit . connect ( walletTo ) ;
14- console . log ( "Connected to contract" )
15- let output = await contractWithSigner . deposit ( _amount ) ;
16- console . log ( output )
11+ context ( 'user can' , function ( ) {
12+ it ( "deposit funds for staking" , async function ( ) {
13+ const contract = this . singlePlayerCommit ;
1714
18- expect ( 1 ) . to . equal ( 1 ) ;
19- } ) ;
15+ const contractWithUser = await contract . connect ( userWallet ) ;
16+ console . log ( "Connected to contract with wallet: " + userWallet . address )
17+
18+ const _amountToDeposit = utils . parseEther ( "1.0" ) ;
19+ const _overrides = {
20+ gasLimit : 100000 ,
21+ } ;
22+
23+ //TODO Error: revert Mock on the method is not initialized
24+ expect ( await contractWithUser . deposit ( _amountToDeposit , _overrides ) ) . to . equal ( true ) ;
25+ console . log ( 'deposited funds' )
26+
27+ const _committerBalance = await contract . committerBalance . call ( ) ;
28+ console . log ( _committerBalance ) ;
29+
30+ expect ( _committerBalance ) . to . equal ( _amountToDeposit )
31+ expect ( '_deposit' ) . to . be . calledOnContract ( contract ) ;
32+ expect ( '_changeCommitterBalance' ) . to . be . calledOnContract ( contract ) ;
33+ } ) ;
2034
21- it . skip ( "allows users with sufficient staked funds to stake on a commitment of biking 50 kms" , async function ( ) {
22- // const _activity = "biking";
23- // const _measureIndex = await this.singlePlayerCommit.measureList(0);
24- console . log ( await walletTo . getBalance ( ) ) ;
25- const _activity = await this . singlePlayerCommit . activityList ( 0 ) ;
26- const _measureIndex = 0
27- const _goal = 50 ;
28- const _startTime = Date . now ( ) ;
29- const _stake = 10 ;
30- let contractWithSigner = await this . singlePlayerCommit . connect ( walletTo ) ;
31- let output = await contractWithSigner . makeCommitment ( _activity , _measureIndex , _goal , _startTime , _stake ) ;
32- console . log ( output )
33-
34- expect ( 1 ) . to . equal ( 1 ) ;
35+ it . skip ( 'withdraw deposited funds' , async function ( ) {
36+ expect ( 1 ) . to . equal ( 1 ) ;
37+ } ) ;
38+
39+ it . skip ( "make a commitment of biking 50 kms against stake with deposited funds" , async function ( ) {
40+ // const _activity = "biking";
41+ // const _measureIndex = await this.singlePlayerCommit.measureList(0);
42+ const contractWithSigner = await this . singlePlayerCommit . connect ( userWallet ) ;
43+
44+ console . log ( await userWallet . getBalance ( ) ) ;
45+ const _activity = await this . singlePlayerCommit . activityList ( 0 ) ;
46+ const _measureIndex = 0
47+ const _goal = 50 ;
48+ const _startTime = Date . now ( ) ;
49+ const _stake = 10 ;
50+ await contractWithSigner . makeCommitment ( _activity , _measureIndex , _goal , _startTime , _stake ) ;
51+
52+ expect ( 1 ) . to . equal ( 1 ) ;
53+ } ) ;
3554 } ) ;
3655
56+
3757}
0 commit comments