@@ -22,11 +22,11 @@ describe('Single Wallet', () => {
22
22
before ( async ( ) => {
23
23
const [ tip ] = await client . getChainTips ( ) ;
24
24
25
- if ( tip . height >= 200 ) {
25
+ if ( tip . height >= 432 ) {
26
26
return null ;
27
27
}
28
28
29
- await client . generate ( 200 ) ;
29
+ await client . generate ( 432 ) ;
30
30
} ) ;
31
31
32
32
describe ( 'node-level requests' , ( ) => {
@@ -51,18 +51,21 @@ describe('Single Wallet', () => {
51
51
const client = new Client ( config . bitcoin ) ;
52
52
const wallets = await client . listWallets ( ) ;
53
53
54
- wallets . should . eql ( [ 'wallet.dat' ] ) ;
54
+ // wallet is shown as '' unless -wallet set in config
55
+ wallets . should . eql ( [ '' ] ) ;
55
56
} ) ;
56
57
} ) ;
57
58
} ) ;
58
59
59
60
describe ( 'wallet-level requests' , ( ) => {
60
- describe ( 'getAccountAddress()' , ( ) => {
61
- it ( 'should retrieve an account address' , async ( ) => {
62
- const address = await client . getAccountAddress ( 'test' ) ;
63
- const account = await client . getAccount ( address ) ;
64
-
65
- account . should . equal ( 'test' ) ;
61
+ describe ( 'getNewAddressesWithLabel()' , ( ) => {
62
+ it ( 'should retrieve an address with a set label' , async ( ) => {
63
+ const address = await client . getNewAddress ( 'testlabelsingle' ) ;
64
+ const labelList = await client . listLabels ( ) ;
65
+
66
+ labelList . should . be . an . Array ( ) ;
67
+ labelList . should . containEql ( 'testlabelsingle' ) ;
68
+ address . should . be . a . String ( ) ;
66
69
} ) ;
67
70
} ) ;
68
71
@@ -74,51 +77,47 @@ describe('Single Wallet', () => {
74
77
} ) ;
75
78
76
79
it ( 'should support named parameters' , async ( ) => {
77
- const client = new Client ( defaults ( { version : '0.15 .0' } , config . bitcoin ) ) ;
80
+ const client = new Client ( defaults ( { version : '0.17 .0' } , config . bitcoin ) ) ;
78
81
79
- const mainWalletBalance = await client . getBalance ( { account : '*' , minconf : 0 } ) ;
80
- const mainWalletBalanceWithoutParameters = await client . getBalance ( '*' , 0 ) ;
81
- const testWalletBalance = await client . getBalance ( { account : 'test' , minconf : 0 } ) ;
82
+ const mainWalletBalance = await client . getBalance ( { dummy : '*' , minconf : 0 } ) ;
83
+ const mainWalletBalanceWithoutNamedParameters = await client . getBalance ( '*' , 0 ) ;
82
84
83
- mainWalletBalance . should . not . equal ( testWalletBalance ) ;
84
- mainWalletBalanceWithoutParameters . should . equal ( mainWalletBalance ) ;
85
+ mainWalletBalance . should . equal ( mainWalletBalanceWithoutNamedParameters ) ;
85
86
} ) ;
86
87
} ) ;
87
88
88
89
describe ( 'getNewAddress()' , ( ) => {
89
90
it ( 'should return a new bitcoin address' , async ( ) => {
90
- await client . getNewAddress ( 'test' ) ;
91
-
92
- const addresses = await client . getAddressesByAccount ( 'test' ) ;
91
+ const address = await client . getNewAddress ( 'test' ) ;
93
92
94
- addresses . length . should . be . above ( 1 ) ;
93
+ address . should . be . a . String ( ) ;
95
94
} ) ;
96
95
} ) ;
97
96
98
97
describe ( 'listTransactions()' , ( ) => {
99
- it ( 'should return the most recent list of transactions from all accounts using specific count' , async ( ) => {
100
- const address = await client . getNewAddress ( 'test ' ) ;
98
+ it ( 'should return the most recent list of transactions using specific count' , async ( ) => {
99
+ const address = await client . getNewAddress ( 'listspecificcount ' ) ;
101
100
102
101
// Generate 5 transactions.
103
102
for ( let i = 0 ; i < 5 ; i ++ ) {
104
103
await client . sendToAddress ( address , 0.1 ) ;
105
104
}
106
105
107
- const transactions = await client . listTransactions ( 'test ' , 5 ) ;
106
+ const transactions = await client . listTransactions ( '* ' , 5 ) ;
108
107
109
108
transactions . should . be . an . Array ( ) ;
110
109
transactions . length . should . be . greaterThanOrEqual ( 5 ) ;
111
110
} ) ;
112
111
113
- it ( 'should return the most recent list of transactions from all accounts using default count' , async ( ) => {
114
- const transactions = await client . listTransactions ( 'test' ) ;
112
+ it ( 'should return the most recent list of transactions using default count' , async ( ) => {
113
+ const transactions = await client . listTransactions ( ) ;
115
114
116
115
transactions . should . be . an . Array ( ) ;
117
116
transactions . should . matchEach ( value => {
118
117
// Only a small subset of transaction properties are being asserted here to make
119
118
// sure we've received a transaction and not an empty object instead.
120
119
value . should . have . keys (
121
- 'account ' ,
120
+ 'label ' ,
122
121
'address' ,
123
122
'amount' ,
124
123
'category' ,
@@ -131,20 +130,20 @@ describe('Single Wallet', () => {
131
130
} ) ;
132
131
133
132
it ( 'should support named parameters' , async ( ) => {
134
- const address = await client . getNewAddress ( 'test ' ) ;
133
+ const address = await client . getNewAddress ( 'testlistwithparams ' ) ;
135
134
136
135
// Generate 5 transactions.
137
136
for ( let i = 0 ; i < 5 ; i ++ ) {
138
137
await client . sendToAddress ( address , 0.1 ) ;
139
138
}
140
139
141
- let transactions = await new Client ( defaults ( { version : '0.15 .0' } , config . bitcoin ) ) . listTransactions ( { account : 'test' } ) ;
140
+ let transactions = await new Client ( defaults ( { version : '0.17 .0' } , config . bitcoin ) ) . listTransactions ( ) ;
142
141
143
142
transactions . should . be . an . Array ( ) ;
144
143
transactions . length . should . be . greaterThanOrEqual ( 5 ) ;
145
144
146
145
// Make sure `count` is read correctly.
147
- transactions = await new Client ( defaults ( { version : '0.15 .0' } , config . bitcoin ) ) . listTransactions ( { account : 'test' , count : 1 } ) ;
146
+ transactions = await new Client ( defaults ( { version : '0.17 .0' } , config . bitcoin ) ) . listTransactions ( { count : 1 } ) ;
148
147
149
148
transactions . should . be . an . Array ( ) ;
150
149
transactions . should . have . length ( 1 ) ;
@@ -161,15 +160,17 @@ describe('Single Wallet', () => {
161
160
] ;
162
161
const response = await client . command ( batch ) ;
163
162
164
- response . should . eql ( [ [ 'wallet.dat' ] , [ 'wallet.dat' ] , [ 'wallet.dat' ] ] ) ;
163
+ // 0.17 for some reason has wallets shown as ''
164
+ // I'm guessing if you load a wallet specifically it will show it
165
+ response . should . eql ( [ [ '' ] , [ '' ] , [ '' ] ] ) ;
165
166
} ) ;
166
167
167
168
it ( 'should support request parameters in batched requests' , async ( ) => {
168
169
const batch = [ { method : 'getnewaddress' } , { method : 'validateaddress' , parameters : [ 'mkteeBFmGkraJaWN5WzqHCjmbQWVrPo5X3' ] } ] ;
169
170
170
171
const [ newAddress , addressValidation ] = await client . command ( batch ) ;
171
172
172
- addressValidation . should . have . properties ( 'address' , 'ismine ' , 'isvalid ' , 'scriptPubKey ' ) ;
173
+ addressValidation . should . have . properties ( 'address' , 'isvalid ' , 'scriptPubKey ' , 'isscript' , 'iswitness ') ;
173
174
newAddress . should . be . a . String ( ) ;
174
175
} ) ;
175
176
@@ -178,7 +179,7 @@ describe('Single Wallet', () => {
178
179
179
180
const [ validateAddressError , validateAddress ] = await client . command ( batch ) ;
180
181
181
- validateAddress . should . have . properties ( 'address' , 'ismine' , ' isvalid', 'scriptPubKey' ) ;
182
+ validateAddress . should . have . properties ( 'address' , 'isvalid' , 'scriptPubKey' ) ;
182
183
validateAddressError . should . be . an . instanceOf ( RpcError ) ;
183
184
validateAddressError . code . should . equal ( - 1 ) ;
184
185
} ) ;
0 commit comments