@@ -22,15 +22,16 @@ import {
2222 aliceSecret ,
2323 bobAddress ,
2424 carolAddress ,
25- daveAddress ,
25+ daveAddress , faucetAccointId ,
2626 faucetAddress
2727} from "../helper/constants" ;
2828import CodeChain from "../helper/spawn" ;
2929
3030describe ( "Reward = 50, 1 miner" , function ( ) {
31+ // FIXME: Change Number to U64
3132 const MIN_FEE_PAY = 10 ;
3233 const BLOCK_REWARD = 50 ;
33- const FAUCET_INITIAL_CCS = new U64 ( " 18000000000000000000" ) ;
34+ const FAUCET_INITIAL_CCS = 18000000000000000000 ;
3435
3536 let node : CodeChain ;
3637
@@ -45,39 +46,39 @@ describe("Reward = 50, 1 miner", function() {
4546 it ( "Mining an empty block" , async function ( ) {
4647 await node . sdk . rpc . devel . startSealing ( ) ;
4748 expect (
48- await node . sdk . rpc . chain . getBalance ( faucetAddress )
49- ) . to . deep . equal ( FAUCET_INITIAL_CCS ) ;
50- expect ( await node . sdk . rpc . chain . getBalance ( aliceAddress ) ) . to . deep . equal (
51- new U64 ( BLOCK_REWARD )
49+ + ( await node . rpc . chain . getBalance ( { address : faucetAddress . toString ( ) } ) ) !
50+ ) . to . equal ( FAUCET_INITIAL_CCS ) ;
51+ expect ( + ( await node . rpc . chain . getBalance ( { address : aliceAddress . toString ( ) } ) ) ! ) . to . equal (
52+ BLOCK_REWARD
5253 ) ;
53- expect ( await node . sdk . rpc . chain . getBalance ( bobAddress ) ) . to . deep . equal (
54- new U64 ( 0 )
54+ expect ( + ( await node . rpc . chain . getBalance ( { address : bobAddress . toString ( ) } ) ) ! ) . to . equal (
55+ 0
5556 ) ;
56- expect ( await node . sdk . rpc . chain . getBalance ( carolAddress ) ) . to . deep . equal (
57- new U64 ( 0 )
57+ expect ( + ( await node . rpc . chain . getBalance ( { address : carolAddress . toString ( ) } ) ) ! ) . to . equal (
58+ 0
5859 ) ;
59- expect ( await node . sdk . rpc . chain . getBalance ( daveAddress ) ) . to . deep . equal (
60- new U64 ( 0 )
60+ expect ( + ( await node . rpc . chain . getBalance ( { address : daveAddress . toString ( ) } ) ) ! ) . to . equal (
61+ 0
6162 ) ;
6263 } ) ;
6364
6465 it ( "Mining a block with 1 transaction" , async function ( ) {
6566 await node . sendPayTx ( { fee : 10 } ) ;
6667
6768 expect (
68- await node . sdk . rpc . chain . getBalance ( faucetAddress )
69- ) . to . deep . equal ( FAUCET_INITIAL_CCS . minus ( 10 /* fee */ ) ) ;
70- expect ( await node . sdk . rpc . chain . getBalance ( aliceAddress ) ) . to . deep . equal (
71- new U64 ( 4 /* share */ ) . plus ( BLOCK_REWARD )
69+ + ( await node . rpc . chain . getBalance ( { address : faucetAddress . toString ( ) } )
70+ ) ! ) . to . equal ( FAUCET_INITIAL_CCS - 10 /* fee */ ) ;
71+ expect ( + ( await node . rpc . chain . getBalance ( { address : aliceAddress . toString ( ) } ) ) ! ) . to . equal (
72+ 4 /* share */ + BLOCK_REWARD
7273 ) ;
73- expect ( await node . sdk . rpc . chain . getBalance ( bobAddress ) ) . to . deep . equal (
74- new U64 ( 3 /* share */ )
74+ expect ( + ( await node . rpc . chain . getBalance ( { address : bobAddress . toString ( ) } ) ) ! ) . to . deep . equal (
75+ 3 /* share */
7576 ) ;
76- expect ( await node . sdk . rpc . chain . getBalance ( carolAddress ) ) . to . deep . equal (
77- new U64 ( 2 /* share */ )
77+ expect ( + ( await node . rpc . chain . getBalance ( { address : carolAddress . toString ( ) } ) ) ! ) . to . deep . equal (
78+ 2 /* share */
7879 ) ;
79- expect ( await node . sdk . rpc . chain . getBalance ( daveAddress ) ) . to . deep . equal (
80- new U64 ( 1 /* share */ )
80+ expect ( + ( await node . rpc . chain . getBalance ( { address : daveAddress . toString ( ) } ) ) ! ) . to . deep . equal (
81+ 1 /* share */
8182 ) ;
8283 } ) ;
8384
@@ -100,74 +101,72 @@ describe("Reward = 50, 1 miner", function() {
100101 const TOTAL_FEE = 10 + 10 + 15 ;
101102 const TOTAL_MIN_FEE = MIN_FEE_PAY * 3 ;
102103 expect (
103- await node . sdk . rpc . chain . getBalance ( faucetAddress )
104- ) . to . deep . equal ( FAUCET_INITIAL_CCS . minus ( TOTAL_FEE ) ) ;
105- expect ( await node . sdk . rpc . chain . getBalance ( aliceAddress ) ) . to . deep . equal (
106- new U64 ( Math . floor ( ( TOTAL_MIN_FEE * 4 ) / 10 ) /* share */ )
107- . plus ( TOTAL_FEE ) // block author get the remaining fee
108- . minus ( Math . floor ( ( TOTAL_MIN_FEE * 4 ) / 10 ) )
109- . minus ( Math . floor ( ( TOTAL_MIN_FEE * 3 ) / 10 ) )
110- . minus ( Math . floor ( ( TOTAL_MIN_FEE * 2 ) / 10 ) )
111- . minus ( Math . floor ( ( TOTAL_MIN_FEE * 1 ) / 10 ) )
112- . plus ( BLOCK_REWARD )
113- ) ;
114- expect ( await node . sdk . rpc . chain . getBalance ( bobAddress ) ) . to . deep . equal (
115- new U64 ( Math . floor ( ( TOTAL_MIN_FEE * 3 ) / 10 ) /* share */ )
116- ) ;
117- expect ( await node . sdk . rpc . chain . getBalance ( carolAddress ) ) . to . deep . equal (
118- new U64 ( Math . floor ( ( TOTAL_MIN_FEE * 2 ) / 10 ) /* share */ )
119- ) ;
120- expect ( await node . sdk . rpc . chain . getBalance ( daveAddress ) ) . to . deep . equal (
121- new U64 ( Math . floor ( ( TOTAL_MIN_FEE * 1 ) / 10 ) /* share */ )
104+ + ( await node . rpc . chain . getBalance ( { address : faucetAddress . toString ( ) } ) ) ! )
105+ . to . deep . equal ( FAUCET_INITIAL_CCS - TOTAL_FEE ) ;
106+ expect ( + ( await node . rpc . chain . getBalance ( { address : aliceAddress . toString ( ) } ) ) ! ) . to . equal (
107+ Number ( Math . floor ( ( TOTAL_MIN_FEE * 4 ) / 10 ) /* share */ )
108+ + ( TOTAL_FEE ) // block author get the remaining fee
109+ - ( Math . floor ( ( TOTAL_MIN_FEE * 4 ) / 10 ) )
110+ - ( Math . floor ( ( TOTAL_MIN_FEE * 3 ) / 10 ) )
111+ - ( Math . floor ( ( TOTAL_MIN_FEE * 2 ) / 10 ) )
112+ - ( Math . floor ( ( TOTAL_MIN_FEE * 1 ) / 10 ) )
113+ + ( BLOCK_REWARD )
114+ ) ;
115+ expect ( + ( await node . rpc . chain . getBalance ( { address : bobAddress . toString ( ) } ) ) ! ) . to . deep . equal (
116+ Number ( Math . floor ( ( TOTAL_MIN_FEE * 3 ) / 10 ) /* share */ )
117+ ) ;
118+ expect ( + ( await node . rpc . chain . getBalance ( { address : carolAddress . toString ( ) } ) ) ! ) . to . deep . equal (
119+ Number ( Math . floor ( ( TOTAL_MIN_FEE * 2 ) / 10 ) /* share */ )
120+ ) ;
121+ expect ( + ( await node . rpc . chain . getBalance ( { address : daveAddress . toString ( ) } ) ) ! ) . to . deep . equal (
122+ Number ( Math . floor ( ( TOTAL_MIN_FEE * 1 ) / 10 ) /* share */ )
122123 ) ;
123124 } ) ;
124125
125126 it ( "Mining a block with a transaction that pays the author" , async function ( ) {
126127 await node . pay ( aliceAddress , 100 ) ;
127128 expect (
128- await node . sdk . rpc . chain . getBalance ( faucetAddress )
129- ) . to . deep . equal (
130- FAUCET_INITIAL_CCS . minus ( 100 /* pay */ ) . minus ( 10 /* fee */ )
129+ + ( await node . rpc . chain . getBalance ( { address : faucetAddress . toString ( ) } ) ) ! ) . to . equal (
130+ FAUCET_INITIAL_CCS + 100 /* pay */ - 10 /* fee */
131131 ) ;
132- expect ( await node . sdk . rpc . chain . getBalance ( aliceAddress ) ) . to . deep . equal (
133- new U64 ( 100 /* pay */ )
134- . plus ( Math . floor ( ( 10 * 4 ) / 10 ) /* share */ )
135- . plus ( BLOCK_REWARD )
132+ expect ( + ( await node . rpc . chain . getBalance ( { address : aliceAddress . toString ( ) } ) ) ! ) . to . equal (
133+ Number ( 100 /* pay */
134+ + Math . floor ( ( 10 * 4 ) / 10 ) /* share */
135+ + BLOCK_REWARD )
136136 ) ;
137- expect ( await node . sdk . rpc . chain . getBalance ( bobAddress ) ) . to . deep . equal (
138- new U64 ( Math . floor ( ( 10 * 3 ) / 10 ) /* share */ )
137+ expect ( + ( await node . rpc . chain . getBalance ( { address : bobAddress . toString ( ) } ) ) ! ) . to . equal (
138+ Number ( Math . floor ( ( 10 * 3 ) / 10 ) /* share */ )
139139 ) ;
140- expect ( await node . sdk . rpc . chain . getBalance ( carolAddress ) ) . to . deep . equal (
141- new U64 ( Math . floor ( ( 10 * 2 ) / 10 ) /* share */ )
140+ expect ( + ( await node . rpc . chain . getBalance ( { address : carolAddress . toString ( ) } ) ) ! ) . to . equal (
141+ Number ( Math . floor ( ( 10 * 2 ) / 10 ) /* share */ )
142142 ) ;
143- expect ( await node . sdk . rpc . chain . getBalance ( daveAddress ) ) . to . deep . equal (
144- new U64 ( Math . floor ( ( 10 * 1 ) / 10 ) /* share */ )
143+ expect ( + ( await node . rpc . chain . getBalance ( { address : daveAddress . toString ( ) } ) ) ! ) . to . equal (
144+ Number ( Math . floor ( ( 10 * 1 ) / 10 ) /* share */ )
145145 ) ;
146146 } ) ;
147147
148148 it ( "Mining a block with a transaction which author pays someone in" , async function ( ) {
149149 await node . sendPayTx ( { fee : 10 } ) ;
150- const faucetBalance = await node . sdk . rpc . chain . getBalance (
151- faucetAddress
152- ) ;
153- const aliceBalance = await node . sdk . rpc . chain . getBalance ( aliceAddress ) ;
154- const bobBalance = await node . sdk . rpc . chain . getBalance ( bobAddress ) ;
155- const carolBalance = await node . sdk . rpc . chain . getBalance ( carolAddress ) ;
156- const daveBalance = await node . sdk . rpc . chain . getBalance ( daveAddress ) ;
157- expect ( faucetBalance ) . to . deep . equal (
158- FAUCET_INITIAL_CCS . minus ( 10 /* fee */ )
150+ const faucetBalance = + ( await node . rpc . chain . getBalance ( { address : faucetAddress . toString ( ) } ) ) ! ;
151+ const aliceBalance = + ( await node . rpc . chain . getBalance ( { address : aliceAddress . toString ( ) } ) ) ! ;
152+ const bobBalance = + ( await node . rpc . chain . getBalance ( { address : bobAddress . toString ( ) } ) ) ! ;
153+ const carolBalance = + ( await node . rpc . chain . getBalance ( { address : carolAddress . toString ( ) } ) ) ! ;
154+ const daveBalance = + ( await node . rpc . chain . getBalance ( { address : daveAddress . toString ( ) } ) ) ! ;
155+
156+ expect ( faucetBalance ) . to . equal (
157+ FAUCET_INITIAL_CCS - 10 /* fee */
159158 ) ;
160- expect ( aliceBalance ) . to . deep . equal (
161- new U64 ( Math . floor ( ( 10 * 4 ) / 10 ) /* share */ ) . plus ( BLOCK_REWARD )
159+ expect ( aliceBalance ) . to . equal (
160+ Number ( Math . floor ( ( 10 * 4 ) / 10 ) ) /* share */ + BLOCK_REWARD
162161 ) ;
163- expect ( bobBalance ) . to . deep . equal (
164- new U64 ( Math . floor ( ( 10 * 3 ) / 10 ) /* share */ )
162+ expect ( bobBalance ) . to . equal (
163+ Number ( Math . floor ( ( 10 * 3 ) / 10 ) /* share */ )
165164 ) ;
166- expect ( carolBalance ) . to . deep . equal (
167- new U64 ( Math . floor ( ( 10 * 2 ) / 10 ) /* share */ )
165+ expect ( carolBalance ) . to . equal (
166+ Number ( Math . floor ( ( 10 * 2 ) / 10 ) /* share */ )
168167 ) ;
169- expect ( daveBalance ) . to . deep . equal (
170- new U64 ( Math . floor ( ( 10 * 1 ) / 10 ) /* share */ )
168+ expect ( daveBalance ) . to . equal (
169+ Number ( Math . floor ( ( 10 * 1 ) / 10 ) /* share */ )
171170 ) ;
172171
173172 const tx = await node . sdk . core
@@ -179,23 +178,23 @@ describe("Reward = 50, 1 miner", function() {
179178 await node . sdk . rpc . chain . sendSignedTransaction ( tx ) ;
180179
181180 expect (
182- await node . sdk . rpc . chain . getBalance ( faucetAddress )
183- ) . to . deep . equal ( faucetBalance . plus ( 20 /* pay */ ) ) ;
184- expect ( await node . sdk . rpc . chain . getBalance ( aliceAddress ) ) . to . deep . equal (
181+ + ( await node . rpc . chain . getBalance ( { address : faucetAddress . toString ( ) } ) ) !
182+ ) . to . deep . equal ( faucetBalance + ( 20 /* pay */ ) ) ;
183+ expect ( + ( await node . rpc . chain . getBalance ( { address : aliceAddress . toString ( ) } ) ) ! ) . to . deep . equal (
185184 aliceBalance
186- . minus ( 20 /* pay */ )
187- . minus ( 10 /* fee */ )
188- . plus ( Math . floor ( ( 10 * 4 ) / 10 ) /* share */ )
189- . plus ( BLOCK_REWARD )
185+ - ( 20 /* pay */ )
186+ - ( 10 /* fee */ )
187+ + ( Math . floor ( ( 10 * 4 ) / 10 ) /* share */ )
188+ + ( BLOCK_REWARD )
190189 ) ;
191- expect ( await node . sdk . rpc . chain . getBalance ( bobAddress ) ) . to . deep . equal (
192- bobBalance . plus ( Math . floor ( ( 10 * 3 ) / 10 ) )
190+ expect ( + ( await node . rpc . chain . getBalance ( { address : bobAddress . toString ( ) } ) ) ! ) . to . deep . equal (
191+ Number ( bobBalance ) + ( Math . floor ( ( 10 * 3 ) / 10 ) )
193192 ) ;
194- expect ( await node . sdk . rpc . chain . getBalance ( carolAddress ) ) . to . deep . equal (
195- carolBalance . plus ( Math . floor ( ( 10 * 2 ) / 10 ) )
193+ expect ( + ( await node . rpc . chain . getBalance ( { address : carolAddress . toString ( ) } ) ) ! ) . to . deep . equal (
194+ Number ( carolBalance ) + ( Math . floor ( ( 10 * 2 ) / 10 ) )
196195 ) ;
197- expect ( await node . sdk . rpc . chain . getBalance ( daveAddress ) ) . to . deep . equal (
198- daveBalance . plus ( Math . floor ( ( 10 * 1 ) / 10 ) )
196+ expect ( + ( await node . rpc . chain . getBalance ( { address : daveAddress . toString ( ) } ) ) ! ) . to . deep . equal (
197+ Number ( daveBalance ) + ( Math . floor ( ( 10 * 1 ) / 10 ) )
199198 ) ;
200199 } ) ;
201200
0 commit comments