@@ -33,14 +33,19 @@ class IridiumClientTest extends Specification {
33
33
wallet1 = getClass(). getResource(" /iridium/wallet1/wallet.adr" ). readLines(). first()
34
34
35
35
sut2 = new IridiumClient (" localhost" , 14009 )
36
- wallet2 = getClass(). getResource(" /iridium/wallet2/wallet.adr" ). readLines(). first()
37
36
38
37
waitForBalance(sut, wallet1, 1 )
39
- // waitForBalance(sut2, wallet2, 0)
40
38
waitForBlockHeightTotal(sut, 10 )
41
39
waitForBlockHeightTotal(sut2, 10 )
42
40
}
43
41
42
+ void setup () {
43
+ wallet2 = sut2. createAddress()
44
+
45
+ def status = sut. getStatus()
46
+ waitForBlockHeightTotal(sut2, status. getBlockCount(). toInteger())
47
+ }
48
+
44
49
void cleanupSpec () {
45
50
sut. reset()
46
51
sut2. reset()
@@ -139,6 +144,7 @@ class IridiumClientTest extends Specification {
139
144
address != null
140
145
}
141
146
147
+ @Ignore (" ignored until we figure out how that is working in the core" )
142
148
def " CreateAddress with publicKey" () {
143
149
when :
144
150
String address = sut. createAddress(PublicKey . of(" test123" ))
@@ -147,12 +153,25 @@ class IridiumClientTest extends Specification {
147
153
address != null
148
154
}
149
155
150
- def " CreateAddress with privateKey" () {
156
+ def " Import wallet from viewSecretKey and spendSecretKey" () {
157
+ given :
158
+ def testAddress = sut. createAddress()
159
+ def keyPair = sut. getSpendKeys(testAddress)
160
+ def viewKey = sut. getViewKey()
161
+
162
+
151
163
when :
152
- String address = sut. createAddress(PrivateKey . of(" secr3t" ))
164
+ sut2. reset(viewKey)
165
+ String address = sut2. createAddress(PrivateKey . of(keyPair. getSecretKey()))
153
166
154
167
then :
155
- address != null
168
+ address == testAddress
169
+
170
+ when :
171
+ def addresses = sut2. getAddresses()
172
+
173
+ then :
174
+ addresses. size() == 1
156
175
}
157
176
158
177
def " DeleteAddress" () {
@@ -520,14 +539,14 @@ class IridiumClientTest extends Specification {
520
539
private static void waitForBalance (IridiumAPI api , String address , long threshold ) {
521
540
while (api. getBalance(address). availableBalance < threshold) {
522
541
log. info(" Waiting for valid balance >=$threshold on wallet $address ... " )
523
- sleep(1000 )
542
+ sleep(5000 )
524
543
}
525
544
}
526
545
527
546
private static void waitForTransactionConfirmation (IridiumAPI api , String transactionHash ) {
528
547
while (api. getUnconfirmedTransactionHashes(). contains(transactionHash)) {
529
548
log. info(" Waiting for tx $transactionHash to get confirmed..." )
530
- sleep(1000 )
549
+ sleep(5000 )
531
550
}
532
551
}
533
552
@@ -536,15 +555,15 @@ class IridiumClientTest extends Specification {
536
555
def currentHeight
537
556
while ((currentHeight = api. getStatus(). knownBlockCount) && currentHeight < desiredHeight) {
538
557
log. info(" Waiting for blockHeight>$desiredHeight , current blockHeight=$currentHeight ... " )
539
- sleep(1000 )
558
+ sleep(5000 )
540
559
}
541
560
}
542
561
543
562
private static void waitForBlockHeightTotal (IridiumAPI api , int desiredHeight ) {
544
563
def currentHeight
545
564
while ((currentHeight = api. getStatus(). knownBlockCount) && currentHeight < desiredHeight) {
546
565
log. info(" Waiting for blockHeight>$desiredHeight , current blockHeight=$currentHeight ... " )
547
- sleep(1000 )
566
+ sleep(5000 )
548
567
}
549
568
}
550
569
0 commit comments