-
Notifications
You must be signed in to change notification settings - Fork 29
/
TestExtensionsTest.kt
124 lines (111 loc) · 3.64 KB
/
TestExtensionsTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package com.nftco.flow.sdk
import com.nftco.flow.sdk.test.*
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
@FlowEmulatorTest
class TestExtensionsTest {
@FlowTestClient
lateinit var accessAPI: FlowAccessApi
@FlowTestClient
lateinit var asyncAccessApi: AsyncFlowAccessApi
@FlowServiceAccountCredentials
lateinit var serviceAccount: TestAccount
@FlowTestAccount(
contracts = [
FlowTestContractDeployment(
name = "NonFungibleToken",
codeFileLocation = "./flow/NonFungibleToken.cdc"
)
]
)
lateinit var account0: TestAccount
@FlowTestAccount(
signAlgo = SignatureAlgorithm.ECDSA_P256,
balance = 69.0,
contracts = [
FlowTestContractDeployment(
name = "NothingContract",
codeClasspathLocation = "/cadence/NothingContract.cdc",
arguments = [
TestContractArg("name", "The Name"),
TestContractArg("description", "The Description"),
]
)
]
)
lateinit var account1: TestAccount
@FlowTestAccount(
signAlgo = SignatureAlgorithm.ECDSA_SECP256k1,
balance = 420.0,
contracts = [
FlowTestContractDeployment(
name = "EmptyContract",
code = "pub contract EmptyContract { init() { } }"
)
]
)
lateinit var account2: TestAccount
@FlowTestAccount(
contracts = [
FlowTestContractDeployment(
name = "NonFungibleToken",
codeFileLocation = "./flow/NonFungibleToken.cdc"
),
FlowTestContractDeployment(
name = "NothingContract",
codeClasspathLocation = "/cadence/NothingContract.cdc",
arguments = [
TestContractArg("name", "The Name"),
TestContractArg("description", "The Description"),
]
),
FlowTestContractDeployment(
name = "EmptyContract",
code = "pub contract EmptyContract { init() { } }"
)
]
)
lateinit var account3: TestAccount
@FlowTestAccount
lateinit var account4: TestAccount
@FlowTestAccount(
signAlgo = SignatureAlgorithm.ECDSA_SECP256k1,
balance = 420.0,
contracts = [
FlowTestContractDeployment(
name = "ContractInterface",
code = "pub contract interface ContractInterface { }"
),
FlowTestContractDeployment(
name = "ContractSuccessor",
code = """
import ContractInterface from 0xCONTRACTINTERFACE
pub contract ContractSuccessor : ContractInterface { init() { } }
"""
),
]
)
lateinit var account5: TestAccount
@Test
fun `Test extensions work`() {
accessAPI.ping()
asyncAccessApi.ping().get()
assertTrue(serviceAccount.isValid)
assertTrue(account0.isValid)
assertTrue(account1.isValid)
assertTrue(account2.isValid)
assertTrue(account3.isValid)
assertTrue(account4.isValid)
assertTrue(account5.isValid)
val addresses = setOf(
account0.flowAddress,
account1.flowAddress,
account2.flowAddress,
account3.flowAddress,
account4.flowAddress,
account5.flowAddress,
)
assertEquals(6, addresses.size)
}
}