5
5
package testutils
6
6
7
7
import (
8
+ "encoding/json"
8
9
"fmt"
9
- "github.com/Qitmeer/qng/core/types"
10
- "github.com/Qitmeer/qng/params"
11
10
"sync"
12
11
"testing"
13
12
"time"
13
+
14
+ "github.com/Qitmeer/qng/core/types"
15
+ "github.com/Qitmeer/qng/params"
14
16
)
15
17
16
18
func TestHarness (t * testing.T ) {
@@ -91,6 +93,7 @@ func TestSyncUnConfirmedCoinBase(t *testing.T) {
91
93
}
92
94
93
95
h .WaitWalletInit ()
96
+ time .Sleep (10 * time .Second )
94
97
if info , err := h .Client .NodeInfo (); err != nil {
95
98
t .Errorf ("test failed : %v" , err )
96
99
return
@@ -100,7 +103,6 @@ func TestSyncUnConfirmedCoinBase(t *testing.T) {
100
103
t .Errorf ("test failed, expect %v , but got %v" , expect , info .Network )
101
104
return
102
105
}
103
-
104
106
}
105
107
GenerateBlock (t , h , 10 )
106
108
time .Sleep (10 * time .Second )
@@ -131,6 +133,7 @@ func TestSyncConfirmedCoinBase(t *testing.T) {
131
133
}
132
134
133
135
h .WaitWalletInit ()
136
+ time .Sleep (10 * time .Second )
134
137
if info , err := h .Client .NodeInfo (); err != nil {
135
138
t .Errorf ("test failed : %v" , err )
136
139
return
@@ -142,22 +145,20 @@ func TestSyncConfirmedCoinBase(t *testing.T) {
142
145
}
143
146
144
147
}
145
- GenerateBlock (t , h , 20 )
146
- time .Sleep (10 * time .Second )
147
-
148
- GenerateBlock (t , h , 1 )
149
- time .Sleep (10 * time .Second )
148
+ GenerateBlock (t , h , 18 )
149
+ time .Sleep (15 * time .Second )
150
150
b , err := h .wallet .Balance (types .MEERA )
151
151
if err != nil {
152
152
t .Errorf ("test failed : %v" , err )
153
153
return
154
154
}
155
- if b .UnspentAmount .Value != 250000000000 {
156
- t .Errorf ("test failed, expect unspent balance %d, but got %d" , 250000000000 , b .UnspentAmount .Value )
155
+ b1 , _ := json .Marshal (b )
156
+ if b .UnspentAmount .Value != 100000000000 {
157
+ t .Errorf ("test failed, expect unspent balance %d, but got %d %v" , 100000000000 , b .UnspentAmount .Value , string (b1 ))
157
158
return
158
159
}
159
160
if b .UnconfirmedAmount .Value != 800000000000 {
160
- t .Errorf ("test failed, expect unconfirmed balance %d, but got %d" , 800000000000 , b .UnspentAmount .Value )
161
+ t .Errorf ("test failed, expect unconfirmed balance %d, but got %d %v " , 800000000000 , b .UnspentAmount .Value , string ( b1 ) )
161
162
return
162
163
}
163
164
}
@@ -177,7 +178,7 @@ func TestSpent(t *testing.T) {
177
178
return
178
179
}
179
180
h .WaitWalletInit ()
180
-
181
+ time . Sleep ( 10 * time . Second )
181
182
if info , err := h .Client .NodeInfo (); err != nil {
182
183
t .Errorf ("test failed : %v" , err )
183
184
return
@@ -189,26 +190,27 @@ func TestSpent(t *testing.T) {
189
190
}
190
191
191
192
}
192
- GenerateBlock (t , h , 20 )
193
- time .Sleep (10 * time .Second )
194
- GenerateBlock (t , h , 1 )
193
+ GenerateBlock (t , h , 18 )
195
194
time .Sleep (10 * time .Second )
196
195
b , err := h .wallet .Balance (types .MEERA )
197
196
if err != nil {
198
197
t .Errorf ("test failed : %v" , err )
199
198
return
200
199
}
201
- _ , err = h .wallet .SendToAddress ("RmV7i7JoomcHuQCVMN66SiTYUCkRtzQ6fSf" , types .MEERA , 1000 )
200
+ _ , err = h .wallet .SendToAddress ("RmV7i7JoomcHuQCVMN66SiTYUCkRtzQ6fSf" , types .MEERA , 498 )
202
201
if err != nil {
203
202
t .Errorf ("test failed, %v" , err )
203
+ return
204
204
}
205
+ GenerateBlock (t , h , 1 )
206
+ time .Sleep (10 * time .Second )
205
207
b , err = h .wallet .Balance (types .MEERA )
206
208
if err != nil {
207
209
t .Errorf ("test failed : %v" , err )
208
210
return
209
211
}
210
- if b .SpendAmount .Value != 150000000000 {
211
- t .Errorf ("test failed, expect spent balance %d, but got %d" , 200000000000 , b .UnspentAmount .Value )
212
+ if b .SpendAmount .Value != 50000000000 {
213
+ t .Errorf ("test failed, expect spent balance %d, but got %d" , 50000000000 , b .SpendAmount .Value )
212
214
return
213
215
}
214
216
GenerateBlock (t , h , 1 )
0 commit comments