forked from jiang-24-gdufs/createRandomEVMWalletsCSV
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.test.js
More file actions
59 lines (51 loc) · 1.5 KB
/
index.test.js
File metadata and controls
59 lines (51 loc) · 1.5 KB
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
const ethers = require('ethers');
const createEVMWalletCsv = require('./index');
const fs = require('fs');
const csv = require('csv-parser');
describe('createEVMWalletCsv', () => {
test('should read and parse the CSV file correctly', async () => {
const stamp = Date.now();
const csvpath = `./w1-${stamp}.csv`
await createEVMWalletCsv({
number: 10,
path: csvpath,
});
const results = [];
fs.createReadStream(csvpath)
.pipe(csv())
.on('data', (data) => {
results.push(data);
})
.on('end', () => {
expect(results.length).toBeGreaterThan(0);
expect(results.length).toBe(10);
results.forEach((row, i) => {
expect(row).toHaveProperty('index', i.toString());
expect(row).toHaveProperty('privateKey');
expect(row).toHaveProperty('address');
});
});
});
test('should read and parse the CSV file with custom parameter correctly', async () => {
const stamp = Date.now();
const csvpath = `./w2-${stamp}.csv`
await createEVMWalletCsv({
path: csvpath,
privateKeyProps: 'pk',
addressProps: 'addr'
});
const results = [];
fs.createReadStream(csvpath)
.pipe(csv())
.on('data', (data) => {
results.push(data);
})
.on('end', () => {
expect(results.length).toBe(100);
results.forEach((row) => {
expect(row).toHaveProperty('pk');
expect(row).toHaveProperty('addr');
});
});
});
});