@alephium/web3 0.2.0-rc.8 → 0.2.0-test.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/.eslintignore +2 -2
  2. package/.eslintrc.json +21 -0
  3. package/LICENSE +165 -0
  4. package/README.md +135 -2
  5. package/contracts/add/add.ral +13 -0
  6. package/contracts/greeter_main.ral +1 -1
  7. package/contracts/main.ral +4 -0
  8. package/contracts/sub/sub.ral +10 -0
  9. package/contracts/test/metadata.ral +18 -0
  10. package/contracts/test/warnings.ral +8 -0
  11. package/dist/alephium-web3.min.js +1 -1
  12. package/dist/alephium-web3.min.js.LICENSE.txt +17 -0
  13. package/dist/alephium-web3.min.js.map +1 -1
  14. package/dist/scripts/create-project.js +1 -1
  15. package/dist/src/api/api-alephium.d.ts +6 -19
  16. package/dist/src/api/api-explorer.d.ts +16 -16
  17. package/dist/src/api/index.js +1 -5
  18. package/dist/src/contract/contract.d.ts +16 -31
  19. package/dist/src/contract/contract.js +96 -123
  20. package/dist/src/contract/index.js +1 -5
  21. package/dist/src/index.d.ts +0 -1
  22. package/dist/src/index.js +1 -19
  23. package/dist/src/signer/index.d.ts +1 -0
  24. package/dist/src/signer/index.js +2 -5
  25. package/dist/src/signer/node-wallet.d.ts +11 -0
  26. package/dist/src/signer/node-wallet.js +57 -0
  27. package/dist/src/signer/signer.js +1 -5
  28. package/dist/src/test/index.d.ts +6 -0
  29. package/dist/src/test/index.js +41 -0
  30. package/dist/src/test/privatekey-wallet.d.ts +11 -0
  31. package/dist/src/test/privatekey-wallet.js +68 -0
  32. package/dist/src/transaction/index.d.ts +1 -0
  33. package/dist/src/transaction/index.js +2 -5
  34. package/dist/src/transaction/sign-verify.d.ts +2 -0
  35. package/dist/src/transaction/sign-verify.js +58 -0
  36. package/dist/src/utils/index.d.ts +1 -0
  37. package/dist/src/utils/index.js +2 -5
  38. package/dist/src/utils/password-crypto.d.ts +2 -0
  39. package/dist/src/utils/password-crypto.js +69 -0
  40. package/dist/src/utils/utils.d.ts +2 -3
  41. package/dist/src/utils/utils.js +15 -16
  42. package/gitignore +9 -0
  43. package/package.json +32 -6
  44. package/scripts/create-project.ts +1 -1
  45. package/src/api/api-alephium.ts +0 -14
  46. package/src/contract/contract.ts +102 -176
  47. package/src/contract/ralph.test.ts +178 -0
  48. package/src/fixtures/address.json +36 -0
  49. package/src/fixtures/balance.json +9 -0
  50. package/src/fixtures/self-clique.json +19 -0
  51. package/src/fixtures/transaction.json +13 -0
  52. package/src/fixtures/transactions.json +179 -0
  53. package/src/index.ts +0 -2
  54. package/src/signer/fixtures/genesis.json +26 -0
  55. package/src/signer/fixtures/wallets.json +26 -0
  56. package/src/signer/index.ts +1 -0
  57. package/src/signer/node-wallet.ts +65 -0
  58. package/src/test/index.ts +31 -0
  59. package/src/test/privatekey-wallet.ts +57 -0
  60. package/src/transaction/index.ts +1 -0
  61. package/src/transaction/sign-verify.test.ts +50 -0
  62. package/src/transaction/sign-verify.ts +39 -0
  63. package/src/utils/address.test.ts +47 -0
  64. package/src/utils/djb2.test.ts +35 -0
  65. package/src/utils/index.ts +1 -0
  66. package/src/utils/password-crypto.test.ts +27 -0
  67. package/src/utils/password-crypto.ts +77 -0
  68. package/src/utils/utils.test.ts +161 -0
  69. package/src/utils/utils.ts +7 -7
  70. package/templates/base/package.json +1 -1
  71. package/templates/react/package.json +1 -1
  72. package/test/contract.test.ts +213 -0
  73. package/test/events.test.ts +141 -0
  74. package/test/transaction.test.ts +73 -0
  75. package/jest-config.json +0 -11
@@ -0,0 +1,213 @@
1
+ /*
2
+ Copyright 2018 - 2022 The Alephium Authors
3
+ This file is part of the alephium project.
4
+
5
+ The library is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Lesser General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ The library is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Lesser General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Lesser General Public License
16
+ along with the library. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ import * as fs from 'fs'
20
+ import * as path from 'path'
21
+ import { setCurrentNodeProvider } from '../src'
22
+ import { Contract, Project, Script, TestContractParams } from '../src/contract'
23
+ import { testNodeWallet } from '../src/test'
24
+ import { addressFromContractId } from '../src/utils'
25
+
26
+ describe('contract', function () {
27
+ async function testSuite1() {
28
+ setCurrentNodeProvider('http://127.0.0.1:22973')
29
+ await Project.build()
30
+
31
+ // ignore unused private function warnings
32
+ const add = Project.contract('add/add.ral', { errorOnWarnings: false })
33
+ const sub = Project.contract('sub/sub.ral')
34
+
35
+ const subState = sub.toState({ result: 0 }, { alphAmount: BigInt('1000000000000000000') })
36
+ const testParams: TestContractParams = {
37
+ initialFields: { sub: subState.contractId, result: 0 },
38
+ testArgs: { array: [2, 1] },
39
+ existingContracts: [subState]
40
+ }
41
+ const testResult = await add.testPublicMethod('add', testParams)
42
+ expect(testResult.returns).toEqual([[3, 1]])
43
+ expect(testResult.contracts[0].codeHash).toEqual(sub.codeHash)
44
+ expect(testResult.contracts[0].fields.result).toEqual(1)
45
+ expect(testResult.contracts[1].codeHash).toEqual(add.codeHash)
46
+ expect(testResult.contracts[1].fields.sub).toEqual(subState.contractId)
47
+ expect(testResult.contracts[1].fields.result).toEqual(3)
48
+ const events = testResult.events.sort((a, b) => a.name.localeCompare(b.name))
49
+ expect(events[0].name).toEqual('Add')
50
+ expect(events[0].fields.x).toEqual(2)
51
+ expect(events[0].fields.y).toEqual(1)
52
+ expect(events[1].name).toEqual('Sub')
53
+ expect(events[1].fields.x).toEqual(2)
54
+ expect(events[1].fields.y).toEqual(1)
55
+
56
+ const testResultPrivate = await add.testPrivateMethod('addPrivate', testParams)
57
+ expect(testResultPrivate.returns).toEqual([[3, 1]])
58
+
59
+ const signer = await testNodeWallet()
60
+
61
+ const subDeployTx = await sub.transactionForDeployment(signer, {
62
+ initialFields: { result: 0 },
63
+ initialTokenAmounts: []
64
+ })
65
+ const subContractId = subDeployTx.contractId
66
+ const subContractAddress = addressFromContractId(subContractId)
67
+ expect(subDeployTx.fromGroup).toEqual(0)
68
+ expect(subDeployTx.toGroup).toEqual(0)
69
+ const subSubmitResult = await signer.submitTransaction(subDeployTx.unsignedTx, subDeployTx.txId)
70
+ expect(subSubmitResult.fromGroup).toEqual(0)
71
+ expect(subSubmitResult.toGroup).toEqual(0)
72
+ expect(subSubmitResult.txId).toEqual(subDeployTx.txId)
73
+
74
+ const addDeployTx = await add.transactionForDeployment(signer, {
75
+ initialFields: { sub: subContractId, result: 0 },
76
+ initialTokenAmounts: []
77
+ })
78
+ expect(addDeployTx.fromGroup).toEqual(0)
79
+ expect(addDeployTx.toGroup).toEqual(0)
80
+ const addSubmitResult = await signer.submitTransaction(addDeployTx.unsignedTx, addDeployTx.txId)
81
+ expect(addSubmitResult.fromGroup).toEqual(0)
82
+ expect(addSubmitResult.toGroup).toEqual(0)
83
+ expect(addSubmitResult.txId).toEqual(addDeployTx.txId)
84
+
85
+ const addContractId = addDeployTx.contractId
86
+ const addContractAddress = addressFromContractId(addContractId)
87
+
88
+ // Check state for add/sub before main script is executed
89
+ let fetchedSubState = await sub.fetchState(subContractAddress, 0)
90
+ expect(fetchedSubState.fields.result).toEqual(0)
91
+ let fetchedAddState = await add.fetchState(addContractAddress, 0)
92
+ expect(fetchedAddState.fields.sub).toEqual(subContractId)
93
+ expect(fetchedAddState.fields.result).toEqual(0)
94
+
95
+ const main = Project.script('main.ral')
96
+ const mainScriptTx = await main.transactionForDeployment(signer, {
97
+ initialFields: { addContractId: addContractId }
98
+ })
99
+ expect(mainScriptTx.fromGroup).toEqual(0)
100
+ expect(mainScriptTx.toGroup).toEqual(0)
101
+ const mainSubmitResult = await signer.submitTransaction(mainScriptTx.unsignedTx, mainScriptTx.txId)
102
+ expect(mainSubmitResult.fromGroup).toEqual(0)
103
+ expect(mainSubmitResult.toGroup).toEqual(0)
104
+
105
+ // Check state for add/sub after main script is executed
106
+ fetchedSubState = await sub.fetchState(subContractAddress, 0)
107
+ expect(fetchedSubState.fields.result).toEqual(1)
108
+ fetchedAddState = await add.fetchState(addContractAddress, 0)
109
+ expect(fetchedAddState.fields.sub).toEqual(subContractId)
110
+ expect(fetchedAddState.fields.result).toEqual(3)
111
+ }
112
+
113
+ async function testSuite2() {
114
+ setCurrentNodeProvider('http://127.0.0.1:22973')
115
+ await Project.build()
116
+
117
+ const greeter = Project.contract('greeter/greeter.ral')
118
+
119
+ const testParams: TestContractParams = {
120
+ initialFields: { btcPrice: 1 }
121
+ }
122
+ const testResult = await greeter.testPublicMethod('greet', testParams)
123
+ expect(testResult.returns).toEqual([1])
124
+ expect(testResult.contracts[0].codeHash).toEqual(greeter.codeHash)
125
+ expect(testResult.contracts[0].fields.btcPrice).toEqual(1)
126
+
127
+ const signer = await testNodeWallet()
128
+
129
+ const deployTx = await greeter.transactionForDeployment(signer, {
130
+ initialFields: { btcPrice: 1 },
131
+ initialTokenAmounts: []
132
+ })
133
+ expect(deployTx.fromGroup).toEqual(0)
134
+ expect(deployTx.toGroup).toEqual(0)
135
+ const submitResult = await signer.submitTransaction(deployTx.unsignedTx, deployTx.txId)
136
+ expect(submitResult.fromGroup).toEqual(0)
137
+ expect(submitResult.toGroup).toEqual(0)
138
+ expect(submitResult.txId).toEqual(deployTx.txId)
139
+
140
+ const greeterContractId = deployTx.contractId
141
+ const main = Project.script('greeter_main.ral')
142
+
143
+ const mainScriptTx = await main.transactionForDeployment(signer, {
144
+ initialFields: { greeterContractId: greeterContractId }
145
+ })
146
+ expect(mainScriptTx.fromGroup).toEqual(0)
147
+ expect(mainScriptTx.toGroup).toEqual(0)
148
+ const mainSubmitResult = await signer.submitTransaction(mainScriptTx.unsignedTx, mainScriptTx.txId)
149
+ expect(mainSubmitResult.fromGroup).toEqual(0)
150
+ expect(mainSubmitResult.toGroup).toEqual(0)
151
+ }
152
+
153
+ it('should test contracts', async () => {
154
+ await testSuite1()
155
+ await testSuite2()
156
+ })
157
+
158
+ function loadJson(fileName: string) {
159
+ const filePath = path.resolve(process.cwd() + path.sep + fileName)
160
+ const rawData = fs.readFileSync(filePath).toString()
161
+ return JSON.parse(rawData)
162
+ }
163
+
164
+ function loadContract(fileName: string) {
165
+ Contract.fromJson(loadJson(fileName))
166
+ }
167
+
168
+ function loadScript(fileName: string) {
169
+ Script.fromJson(loadJson(fileName))
170
+ }
171
+
172
+ it('should load source files by order', async () => {
173
+ const sourceFiles = await Project['loadSourceFiles']('./contracts') // `loadSourceFiles` is a private method
174
+ expect(sourceFiles.length).toEqual(8)
175
+ sourceFiles.slice(0, 5).forEach((c) => expect(c.type).toEqual(0)) // contracts
176
+ sourceFiles.slice(5, 7).forEach((s) => expect(s.type).toEqual(1)) // scripts
177
+ sourceFiles.slice(7).forEach((i) => expect(i.type).toEqual(3)) // interfaces
178
+ })
179
+
180
+ it('should load contract from json', async () => {
181
+ loadContract('./artifacts/add/add.ral.json')
182
+ loadContract('./artifacts/sub/sub.ral.json')
183
+ loadScript('./artifacts/main.ral.json')
184
+
185
+ loadContract('./artifacts/greeter/greeter.ral.json')
186
+ loadScript('./artifacts/greeter_main.ral.json')
187
+ })
188
+
189
+ it('should extract metadata of contracts', async () => {
190
+ setCurrentNodeProvider('http://127.0.0.1:22973')
191
+ await Project.build()
192
+
193
+ const contract = Project.contract('test/metadata.ral', { errorOnWarnings: false })
194
+ expect(contract.functions.map((func) => func.name)).toEqual(['foo', 'bar', 'baz'])
195
+ expect(contract.publicFunctions()).toEqual(['foo'])
196
+ expect(contract.usingPreapprovedAssetsFunctions()).toEqual(['foo'])
197
+ expect(contract.usingAssetsInContractFunctions()).toEqual(['bar'])
198
+ })
199
+
200
+ it('should handle compiler warnings', async () => {
201
+ setCurrentNodeProvider('http://127.0.0.1:22973')
202
+ await Project.build()
203
+ const contract = Project.contract('test/warnings.ral', { errorOnWarnings: false })
204
+ expect(contract.publicFunctions()).toEqual(['foo'])
205
+
206
+ expect(() => Project.contract('test/warnings.ral')).toThrowError(
207
+ 'Compilation warnings:\n - Found unused variables in Warnings: foo.y\n - Found unused fields in Warnings: b'
208
+ )
209
+ expect(() => Project.contract('test/warnings.ral', { ignoreUnusedConstantsWarnings: false })).toThrowError(
210
+ 'Compilation warnings:\n - Found unused variables in Warnings: foo.y\n - Found unused constants in Warnings: C\n - Found unused fields in Warnings: b'
211
+ )
212
+ })
213
+ })
@@ -0,0 +1,141 @@
1
+ /*
2
+ Copyright 2018 - 2022 The Alephium Authors
3
+ This file is part of the alephium project.
4
+
5
+ The library is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Lesser General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ The library is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Lesser General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Lesser General Public License
16
+ along with the library. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ import { subscribeToEvents } from '../src/contract/events'
20
+ import { Project } from '../src/contract'
21
+ import { NodeWallet, SignExecuteScriptTxParams } from '../src/signer'
22
+ import { ContractEvent } from '../src/api/api-alephium'
23
+ import { testNodeWallet } from '../src/test'
24
+ import { SubscribeOptions, timeout } from '../src/utils'
25
+ import { setCurrentNodeProvider } from '../src'
26
+
27
+ describe('events', function () {
28
+ async function deployContract(signer: NodeWallet): Promise<[string, string]> {
29
+ setCurrentNodeProvider('http://127.0.0.1:22973')
30
+ await Project.build()
31
+ const sub = Project.contract('sub/sub.ral')
32
+ const subDeployTx = await sub.transactionForDeployment(signer, {
33
+ initialFields: { result: 0 },
34
+ initialTokenAmounts: []
35
+ })
36
+ const subContractId = subDeployTx.contractId
37
+ const subSubmitResult = await signer.submitTransaction(subDeployTx.unsignedTx, subDeployTx.txId)
38
+ expect(subSubmitResult.txId).toEqual(subDeployTx.txId)
39
+
40
+ // ignore unused private function warnings
41
+ const add = Project.contract('add/add.ral', { errorOnWarnings: false })
42
+ const addDeployTx = await add.transactionForDeployment(signer, {
43
+ initialFields: { sub: subContractId, result: 0 },
44
+ initialTokenAmounts: []
45
+ })
46
+ const addSubmitResult = await signer.submitTransaction(addDeployTx.unsignedTx, addDeployTx.txId)
47
+ expect(addSubmitResult.txId).toEqual(addDeployTx.txId)
48
+ return [addDeployTx.contractAddress, addDeployTx.contractId]
49
+ }
50
+
51
+ async function executeScript(params: SignExecuteScriptTxParams, signer: NodeWallet, times: number) {
52
+ for (let i = 0; i < times; i++) {
53
+ const scriptTx = await signer.buildScriptTx(params)
54
+ await signer.submitTransaction(scriptTx.unsignedTx, scriptTx.txId)
55
+ }
56
+ }
57
+
58
+ it('should subscribe contract events', async () => {
59
+ setCurrentNodeProvider('http://127.0.0.1:22973')
60
+ await Project.build()
61
+ const signer = await testNodeWallet()
62
+
63
+ const [contractAddress, contractId] = await deployContract(signer)
64
+ const events: Array<ContractEvent> = []
65
+ const subscriptOptions: SubscribeOptions<ContractEvent> = {
66
+ pollingInterval: 500,
67
+ messageCallback: (event: ContractEvent): Promise<void> => {
68
+ events.push(event)
69
+ return Promise.resolve()
70
+ },
71
+ errorCallback: (error: any, subscription): Promise<void> => {
72
+ console.log(error)
73
+ subscription.unsubscribe()
74
+ return Promise.resolve()
75
+ }
76
+ }
77
+ const subscription = subscribeToEvents(subscriptOptions, contractAddress)
78
+ const script = Project.script('main.ral')
79
+ const scriptTxParams = await script.paramsForDeployment({
80
+ initialFields: { addContractId: contractId },
81
+ signerAddress: (await signer.getAccounts())[0].address
82
+ })
83
+ await executeScript(scriptTxParams, signer, 3)
84
+ await timeout(3000)
85
+
86
+ expect(events.length).toEqual(3)
87
+ events.forEach((event) => {
88
+ expect(event.fields).toEqual([
89
+ { type: 'U256', value: '2' },
90
+ { type: 'U256', value: '1' }
91
+ ])
92
+ })
93
+ expect(subscription.currentEventCount()).toEqual(events.length)
94
+
95
+ subscription.unsubscribe()
96
+ }, 15000)
97
+
98
+ it('should cancel event subscription', async () => {
99
+ setCurrentNodeProvider('http://127.0.0.1:22973')
100
+ await Project.build()
101
+ const signer = await testNodeWallet()
102
+
103
+ const [contractAddress, contractId] = await deployContract(signer)
104
+ const events: Array<ContractEvent> = []
105
+ const subscriptOptions = {
106
+ pollingInterval: 500,
107
+ messageCallback: (event: ContractEvent): Promise<void> => {
108
+ events.push(event)
109
+ return Promise.resolve()
110
+ },
111
+ errorCallback: (error: any, subscription): Promise<void> => {
112
+ console.log(error)
113
+ subscription.unsubscribe()
114
+ return Promise.resolve()
115
+ }
116
+ }
117
+ const subscription = subscribeToEvents(subscriptOptions, contractAddress)
118
+ const script = Project.script('main.ral')
119
+ const scriptTx0 = await script.transactionForDeployment(signer, {
120
+ initialFields: { addContractId: contractId }
121
+ })
122
+ await signer.submitTransaction(scriptTx0.unsignedTx, scriptTx0.txId)
123
+ await timeout(1500)
124
+ subscription.unsubscribe()
125
+
126
+ expect(events.length).toEqual(1)
127
+ expect(events[0].txId).toEqual(scriptTx0.txId)
128
+ expect(events[0].fields).toEqual([
129
+ { type: 'U256', value: '2' },
130
+ { type: 'U256', value: '1' }
131
+ ])
132
+ expect(subscription.currentEventCount()).toEqual(events.length)
133
+
134
+ const scriptTx1 = await script.transactionForDeployment(signer, {
135
+ initialFields: { addContractId: contractId }
136
+ })
137
+ await signer.submitTransaction(scriptTx1.unsignedTx, scriptTx1.txId)
138
+ await timeout(1500)
139
+ expect(events.length).toEqual(1)
140
+ })
141
+ })
@@ -0,0 +1,73 @@
1
+ /*
2
+ Copyright 2018 - 2022 The Alephium Authors
3
+ This file is part of the alephium project.
4
+
5
+ The library is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Lesser General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ The library is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Lesser General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Lesser General Public License
16
+ along with the library. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ import { subscribeToTxStatus } from '../src/transaction/status'
20
+ import { Project } from '../src/contract'
21
+ import { TxStatus } from '../src/api/api-alephium'
22
+ import { testNodeWallet } from '../src/test'
23
+ import { SubscribeOptions, timeout } from '../src/utils'
24
+ import { setCurrentNodeProvider } from '../src'
25
+
26
+ describe('transactions', function () {
27
+ it('should subscribe transaction status', async () => {
28
+ setCurrentNodeProvider('http://127.0.0.1:22973')
29
+ await Project.build()
30
+ const sub = Project.contract('sub/sub.ral')
31
+ const signer = await testNodeWallet()
32
+ const subDeployTx = await sub.transactionForDeployment(signer, {
33
+ initialFields: { result: 0 },
34
+ initialTokenAmounts: []
35
+ })
36
+
37
+ let txStatus: TxStatus | undefined = undefined
38
+ let counter = 0
39
+ const subscriptOptions: SubscribeOptions<TxStatus> = {
40
+ pollingInterval: 500,
41
+ messageCallback: (status: TxStatus): Promise<void> => {
42
+ txStatus = status
43
+ counter = counter + 1
44
+ return Promise.resolve()
45
+ },
46
+ errorCallback: (error: any, subscription): Promise<void> => {
47
+ console.log(error)
48
+ subscription.unsubscribe()
49
+ return Promise.resolve()
50
+ }
51
+ }
52
+
53
+ const counterBeforeSubscribe = counter
54
+
55
+ const subscription = subscribeToTxStatus(subscriptOptions, subDeployTx.txId)
56
+ await timeout(1500)
57
+ expect(txStatus).toMatchObject({ type: 'TxNotFound' })
58
+
59
+ await signer.submitTransaction(subDeployTx.unsignedTx, subDeployTx.txId)
60
+ await timeout(1500)
61
+ expect(txStatus).toMatchObject({ type: 'Confirmed' })
62
+
63
+ expect(counterBeforeSubscribe).toBeLessThan(counter)
64
+
65
+ subscription.unsubscribe()
66
+
67
+ const counterAfterUnsubscribe = counter
68
+ await timeout(1500)
69
+ expect(txStatus).toMatchObject({ type: 'Confirmed' })
70
+ // There maybe a pending request when we unsubscribe
71
+ expect([counter, counter - 1]).toContain(counterAfterUnsubscribe)
72
+ }, 10000)
73
+ })
package/jest-config.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "testPathIgnorePatterns": [".*/node_modules/"],
3
- "transform": {
4
- "^.+\\.(t|j)sx?$": "ts-jest"
5
- },
6
- "testMatch": ["**/*.test.ts"],
7
- "moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
8
- "collectCoverage": true,
9
- "coverageDirectory": "./coverage/",
10
- "collectCoverageFrom": ["src/**/*.ts"]
11
- }