@@ -18,7 +18,11 @@ describe('balance', () => {
18
18
await connection . synchronize ( )
19
19
} )
20
20
21
- const generateAddress = ( liveBalance : string | bigint , sentBalance : string | bigint , pendingBalance : string | bigint ) => {
21
+ const generateAddress = (
22
+ liveBalance : string | bigint ,
23
+ sentBalance : string | bigint ,
24
+ pendingBalance : string | bigint
25
+ ) => {
22
26
const addr = Math . round ( Math . random ( ) * 100000000 ) . toString ( )
23
27
const address : Address = {
24
28
walletId : '1' ,
@@ -31,6 +35,7 @@ describe('balance', () => {
31
35
sentBalance : sentBalance . toString ( ) ,
32
36
pendingBalance : pendingBalance . toString ( ) ,
33
37
balance : '0' ,
38
+ totalBalance : '0' ,
34
39
blake160 : '0x36c329ed630d6ce750712a477543672adab57f4c' ,
35
40
version : AddressVersion . Testnet ,
36
41
}
@@ -53,15 +58,10 @@ describe('balance', () => {
53
58
54
59
it ( 'sent to others' , async ( ) => {
55
60
// have 1000, sent to others 200, and refund 800
56
- const addresses = [
57
- generateAddress ( '0' , '0' , '1000' ) ,
58
- generateAddress ( '0' , '800' , '0' ) ,
59
- ]
61
+ const addresses = [ generateAddress ( '0' , '0' , '1000' ) , generateAddress ( '0' , '800' , '0' ) ]
60
62
61
63
const addrs : AddressEntity [ ] = await AddressDao . create ( addresses )
62
- const balance : bigint = addrs
63
- . map ( addr => BigInt ( addr . balance ( ) ) )
64
- . reduce ( ( result , c ) => result + c , BigInt ( 0 ) )
64
+ const balance : bigint = addrs . map ( addr => BigInt ( addr . balance ( ) ) ) . reduce ( ( result , c ) => result + c , BigInt ( 0 ) )
65
65
66
66
expect ( balance ) . toEqual ( BigInt ( 800 ) )
67
67
} )
@@ -74,24 +74,17 @@ describe('balance', () => {
74
74
generateAddress ( '0' , '800' , '0' ) ,
75
75
]
76
76
const addrs : AddressEntity [ ] = await AddressDao . create ( addresses )
77
- const balance : bigint = addrs
78
- . map ( addr => BigInt ( addr . balance ( ) ) )
79
- . reduce ( ( result , c ) => result + c , BigInt ( 0 ) )
77
+ const balance : bigint = addrs . map ( addr => BigInt ( addr . balance ( ) ) ) . reduce ( ( result , c ) => result + c , BigInt ( 0 ) )
80
78
81
79
expect ( balance ) . toEqual ( BigInt ( 1000 ) )
82
80
} )
83
81
84
82
it ( 'sent to others with 10 shannon fee' , async ( ) => {
85
83
// have 1000, sent to others 200, and refund 790, with 10 shannon fee
86
- const addresses = [
87
- generateAddress ( '0' , '0' , '1000' ) ,
88
- generateAddress ( '0' , '790' , '0' ) ,
89
- ]
84
+ const addresses = [ generateAddress ( '0' , '0' , '1000' ) , generateAddress ( '0' , '790' , '0' ) ]
90
85
91
86
const addrs : AddressEntity [ ] = await AddressDao . create ( addresses )
92
- const balance : bigint = addrs
93
- . map ( addr => BigInt ( addr . balance ( ) ) )
94
- . reduce ( ( result , c ) => result + c , BigInt ( 0 ) )
87
+ const balance : bigint = addrs . map ( addr => BigInt ( addr . balance ( ) ) ) . reduce ( ( result , c ) => result + c , BigInt ( 0 ) )
95
88
96
89
expect ( balance ) . toEqual ( BigInt ( 790 ) )
97
90
} )
@@ -105,9 +98,7 @@ describe('balance', () => {
105
98
]
106
99
107
100
const addrs : AddressEntity [ ] = await AddressDao . create ( addresses )
108
- const balance : bigint = addrs
109
- . map ( addr => BigInt ( addr . balance ( ) ) )
110
- . reduce ( ( result , c ) => result + c , BigInt ( 0 ) )
101
+ const balance : bigint = addrs . map ( addr => BigInt ( addr . balance ( ) ) ) . reduce ( ( result , c ) => result + c , BigInt ( 0 ) )
111
102
112
103
expect ( balance ) . toEqual ( BigInt ( 990 ) )
113
104
} )
0 commit comments