-
Notifications
You must be signed in to change notification settings - Fork 29
/
ProjectTestExtensionsTest.kt
111 lines (99 loc) · 3.44 KB
/
ProjectTestExtensionsTest.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
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
@FlowEmulatorProjectTest(
flowJsonLocation = "flow/flow.json",
serviceAccountAddress = "f8d6e0586b0a20c7",
serviceAccountPublicKey = "828edaffa000bc6bcf1ed75bfc87a13129d69ff36b3c21143075f10f951692980d2c55bdfe82319a55a2a295b75f7224462d92107d8e3abc341079ba307e502c",
serviceAccountPrivateKey = "ac1af8be8d0028ad50f0656b53a6342a7d12186a3b212a993344d6e70f857d6b",
serviceAccountSignAlgo = SignatureAlgorithm.ECDSA_P256,
serviceAccountHashAlgo = HashAlgorithm.SHA3_256,
serviceAccountKeyIndex = 0
)
class ProjectTestExtensionsTest {
@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
@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)
val addresses = setOf(
account0.flowAddress,
account1.flowAddress,
account2.flowAddress,
account3.flowAddress,
account4.flowAddress
)
assertEquals(5, addresses.size)
}
}