forked from luckybean/scholar-block-producers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
73 lines (69 loc) · 2.08 KB
/
test.js
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
const fs = require('fs');
const test = require('tape');
const path = require('path');
const yaml = require('js-yaml');
const glob = require('glob');
test('validate block-producers configs', t => {
glob.sync(path.join(__dirname, 'block-producers', '*.yml')).forEach(filepath => {
const config = yaml.safeLoad(fs.readFileSync(filepath, 'utf8'));
const {name} = path.parse(filepath)
const requiredFields = [
'account_name',
'owner_public_key',
'active_public_key',
'producer_name',
'block_signing_key',
'telegram_user',
'keybase_user'
];
const optionalFields = [
'domain',
'http',
'p2p',
'agent_name',
'organization_name',
'logo_url',
'timezone',
'website'
];
// Account name longer then 13 characters
if (config.account_name.length > 13) t.fail(`${name} account_name cannot be longer than 13 characters`)
// Required Fields (Fail)
requiredFields.forEach(field => {
if (!config[field]) t.fail(`${name} missing ${field}`);
})
// Optional Fields (Skip)
optionalFields.forEach(field => {
if (!config[field]) t.skip(`${name} missing ${field}`);
})
})
t.end();
})
test('validate developers configs', t => {
glob.sync(path.join(__dirname, 'developers', '*.yml')).forEach(filepath => {
const config = yaml.safeLoad(fs.readFileSync(filepath, 'utf8'));
const {name} = path.parse(filepath)
const requiredFields = [
'account_name',
'owner_public_key',
'active_public_key'
];
const optionalFields = [
'organization_name',
'logo_url',
'timezone',
'website'
];
// Account name longer then 13 characters
if (config.account_name.length > 13) t.fail(`${name} account_name cannot be longer than 13 characters`)
// Required Fields (Fail)
requiredFields.forEach(field => {
if (!config[field]) t.fail(`${name} missing ${field}`);
})
// Optional Fields (Skip)
optionalFields.forEach(field => {
if (!config[field]) t.skip(`${name} missing ${field}`);
})
})
t.end();
})