Skip to content

Commit 8b436d6

Browse files
committed
refactor: Init tests to have Ethereum scope
1 parent 1b0fa91 commit 8b436d6

15 files changed

+173
-165
lines changed

tests/cli/init.test.js

Lines changed: 117 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,128 @@
1-
const fs = require('fs-extra')
21
const path = require('path')
32
const { cliTest } = require('./util')
43

54
describe('Init', () => {
6-
let baseDir = path.join(__dirname, 'init')
5+
const baseDir = path.join(__dirname, 'init')
76

8-
let subgraphDir1 = path.join(baseDir, 'from-example')
9-
let subgraphDir2 = path.join(baseDir, 'from-contract')
10-
let subgraphDir3 = path.join(baseDir, 'from-contract-with-abi')
11-
let subgraphDir4 = path.join(baseDir, 'from-contract-with-abi-and-structs')
12-
let subgraphDir5 = path.join(baseDir, 'from-contract-with-overloaded-elements')
7+
describe('Ethereum', () => {
8+
const ethereumBaseDir = path.join(baseDir, 'ethereum')
139

14-
const removeSubgraphDirs = () => {
15-
if (fs.existsSync(subgraphDir1)) {
16-
fs.removeSync(subgraphDir1)
17-
}
18-
if (fs.existsSync(subgraphDir2)) {
19-
fs.removeSync(subgraphDir2)
20-
}
21-
if (fs.existsSync(subgraphDir3)) {
22-
fs.removeSync(subgraphDir3)
23-
}
24-
if (fs.existsSync(subgraphDir4)) {
25-
fs.removeSync(subgraphDir4)
26-
}
27-
if (fs.existsSync(subgraphDir5)) {
28-
fs.removeSync(subgraphDir5)
29-
}
30-
}
10+
cliTest(
11+
'From example',
12+
[
13+
'init',
14+
'--protocol',
15+
'ethereum',
16+
'--studio',
17+
'--from-example',
18+
'user/example-subgraph',
19+
path.join(ethereumBaseDir, 'from-example'),
20+
],
21+
path.join('init', 'ethereum', 'from-example'),
22+
{
23+
exitCode: 0,
24+
timeout: 100000,
25+
cwd: ethereumBaseDir,
26+
deleteDir: true,
27+
},
28+
)
3129

32-
beforeAll(removeSubgraphDirs)
33-
afterAll(removeSubgraphDirs)
30+
cliTest(
31+
'From contract',
32+
[
33+
'init',
34+
'--protocol',
35+
'ethereum',
36+
'--studio',
37+
'--from-contract',
38+
'0xF87E31492Faf9A91B02Ee0dEAAd50d51d56D5d4d',
39+
'--network',
40+
'mainnet',
41+
'user/subgraph-from-contract',
42+
path.join(ethereumBaseDir, 'from-contract'),
43+
],
44+
path.join('init', 'ethereum', 'from-contract'),
45+
{
46+
exitCode: 0,
47+
timeout: 100000,
48+
cwd: ethereumBaseDir,
49+
deleteDir: true,
50+
},
51+
)
3452

35-
cliTest(
36-
'From example',
37-
[
38-
'init',
39-
'--protocol',
40-
'ethereum',
41-
'--studio',
42-
'--from-example',
43-
'user/example-subgraph',
44-
subgraphDir1
45-
],
46-
'init/from-example',
47-
{
48-
exitCode: 0,
49-
timeout: 100000,
50-
cwd: baseDir,
51-
},
52-
)
53+
cliTest(
54+
'From contract with abi',
55+
[
56+
'init',
57+
'--protocol',
58+
'ethereum',
59+
'--studio',
60+
'--from-contract',
61+
'0xF87E31492Faf9A91B02Ee0dEAAd50d51d56D5d4d',
62+
'--abi',
63+
path.join(ethereumBaseDir, 'abis', 'Marketplace.json'),
64+
'--network',
65+
'mainnet',
66+
'user/subgraph-from-contract-with-abi',
67+
path.join(ethereumBaseDir, 'from-contract-with-abi'),
68+
],
69+
path.join('init', 'ethereum', 'from-contract-with-abi'),
70+
{
71+
exitCode: 0,
72+
timeout: 100000,
73+
cwd: ethereumBaseDir,
74+
deleteDir: true,
75+
},
76+
)
5377

54-
cliTest(
55-
'From contract',
56-
[
57-
'init',
58-
'--protocol',
59-
'ethereum',
60-
'--studio',
61-
'--from-contract',
62-
'0xF87E31492Faf9A91B02Ee0dEAAd50d51d56D5d4d',
63-
'--network',
64-
'mainnet',
65-
'user/subgraph-from-contract',
66-
subgraphDir2,
67-
],
68-
'init/from-contract',
69-
{
70-
exitCode: 0,
71-
timeout: 100000,
72-
cwd: baseDir,
73-
},
74-
)
78+
cliTest(
79+
'From contract with abi and structs',
80+
[
81+
'init',
82+
'--protocol',
83+
'ethereum',
84+
'--studio',
85+
'--from-contract',
86+
'0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e',
87+
'--abi',
88+
path.join(ethereumBaseDir, 'abis', 'SoloMargin.json'),
89+
'--network',
90+
'mainnet',
91+
'user/subgraph-from-contract-with-abi-and-structs',
92+
path.join(ethereumBaseDir, 'from-contract-with-abi-and-structs'),
93+
],
94+
path.join('init', 'ethereum', 'from-contract-with-abi-and-structs'),
95+
{
96+
exitCode: 0,
97+
timeout: 100000,
98+
cwd: ethereumBaseDir,
99+
deleteDir: true,
100+
},
101+
)
75102

76-
cliTest(
77-
'From contract with abi',
78-
[
79-
'init',
80-
'--protocol',
81-
'ethereum',
82-
'--studio',
83-
'--from-contract',
84-
'0xF87E31492Faf9A91B02Ee0dEAAd50d51d56D5d4d',
85-
'--abi',
86-
path.join(baseDir, 'abis', 'Marketplace.json'),
87-
'--network',
88-
'mainnet',
89-
'user/subgraph-from-contract-with-abi',
90-
subgraphDir3,
91-
],
92-
'init/from-contract-with-abi',
93-
{ exitCode: 0, timeout: 100000, cwd: baseDir },
94-
)
95-
96-
cliTest(
97-
'From contract with abi and structs',
98-
[
99-
'init',
100-
'--protocol',
101-
'ethereum',
102-
'--studio',
103-
'--from-contract',
104-
'0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e',
105-
'--abi',
106-
path.join(baseDir, 'abis', 'SoloMargin.json'),
107-
'--network',
108-
'mainnet',
109-
'user/subgraph-from-contract-with-abi-and-structs',
110-
subgraphDir4,
111-
],
112-
'init/from-contract-with-abi-and-structs',
113-
{ exitCode: 0, timeout: 100000, cwd: baseDir },
114-
)
115-
116-
cliTest(
117-
'From contract with overloaded elements',
118-
[
119-
'init',
120-
'--protocol',
121-
'ethereum',
122-
'--studio',
123-
'--from-contract',
124-
'0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e',
125-
'--abi',
126-
path.join(baseDir, 'abis', 'OverloadedElements.json'),
127-
'--network',
128-
'mainnet',
129-
'user/subgraph-from-contract-with-overloaded-elements',
130-
subgraphDir5,
131-
],
132-
'init/from-contract-with-overloaded-elements',
133-
{ exitCode: 0, timeout: 100000, cwd: baseDir },
134-
)
103+
cliTest(
104+
'From contract with overloaded elements',
105+
[
106+
'init',
107+
'--protocol',
108+
'ethereum',
109+
'--studio',
110+
'--from-contract',
111+
'0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e',
112+
'--abi',
113+
path.join(ethereumBaseDir, 'abis', 'OverloadedElements.json'),
114+
'--network',
115+
'mainnet',
116+
'user/subgraph-from-contract-with-overloaded-elements',
117+
path.join(ethereumBaseDir, 'from-contract-with-overloaded-elements'),
118+
],
119+
path.join('init', 'ethereum', 'from-contract-with-overloaded-elements'),
120+
{
121+
exitCode: 0,
122+
timeout: 100000,
123+
cwd: ethereumBaseDir,
124+
deleteDir: true,
125+
},
126+
)
127+
})
135128
})
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)