11package cc.etherspace.calladapter
22
33import cc.etherspace.*
4+ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
45import kotlinx.coroutines.experimental.Deferred
56import kotlinx.coroutines.experimental.runBlocking
67import org.amshove.kluent.*
@@ -12,15 +13,22 @@ import java.math.BigInteger
1213
1314class CoroutineGreeterTest {
1415 private lateinit var greeter: CoroutineGreeter
16+ private lateinit var etherSpace: EtherSpace
17+ private val objectMapper = jacksonObjectMapper()
1518
1619 @Before
1720 fun setUp () {
18- val etherSpace = EtherSpace .build {
19- provider = " https://rinkeby.infura.io/"
20- credentials = WalletCredentials (Tests .TEST_WALLET_KEY )
21- callAdapters + = CoroutineCallAdapter ()
21+ etherSpace = Tests .createEtherSpace()
22+ greeter = Tests .createContract(etherSpace, CoroutineGreeter ::class .java, objectMapper)
23+ }
24+
25+ @Test(expected = IOException ::class )
26+ fun wrongContract () {
27+ runBlocking {
28+ val wrongGreeter = etherSpace.create(" 0xf9746f03bd6f29787994701996dffd7a1007f3a6" , CoroutineGreeter ::class .java)
29+ val receipt = wrongGreeter.newGreeting(" Hello World" ).await()
30+ receipt.success.`should be false `()
2231 }
23- greeter = etherSpace.create(Tests .TEST_CONTRACT_ADDRESS , CoroutineGreeter ::class .java)
2432 }
2533
2634 @Test
@@ -29,8 +37,6 @@ class CoroutineGreeterTest {
2937 val receipt = greeter.newGreeting(" Hello World" ).await()
3038 receipt.blockHash.length.`should be equal to`(66 )
3139 receipt.transactionHash.length.`should be equal to`(66 )
32- receipt.from!! .`should be equal to`(Tests .TEST_WALLET_ADDRESS )
33- receipt.to!! .`should be equal to`(Tests .TEST_CONTRACT_ADDRESS )
3440 receipt.logs.size.`should be greater than`(0 )
3541
3642 val events = receipt.listEvents(CoroutineGreeter .Modified ::class .java)
@@ -51,8 +57,6 @@ class CoroutineGreeterTest {
5157 val receipt = hash.requestTransactionReceipt<Deferred <TransactionReceipt >>().await()
5258 receipt.blockHash.length.`should be equal to`(66 )
5359 receipt.transactionHash.length.`should be equal to`(66 )
54- receipt.from!! .`should be equal to`(Tests .TEST_WALLET_ADDRESS )
55- receipt.to!! .`should be equal to`(Tests .TEST_CONTRACT_ADDRESS )
5660 receipt.logs.size.`should be greater than`(0 )
5761 }
5862 }
@@ -73,7 +77,7 @@ class CoroutineGreeterTest {
7377 }
7478 }
7579
76- @Test(expected = IllegalArgumentException ::class )
80+ @Test(expected = IOException ::class )
7781 fun greet_wrongFunctionName () {
7882 runBlocking {
7983 val greet = greeter.greet_wrongFunctionName().await()
0 commit comments