Skip to content

Commit

Permalink
Update tests and fix test config
Browse files Browse the repository at this point in the history
  • Loading branch information
platfowner committed Jan 9, 2022
1 parent 7e72258 commit 3a1ceaa
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 47 deletions.
42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@
"test_integration_he_protocol": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/3-nodes ./node_modules/mocha/bin/mocha --timeout 640000 test/integration/he_protocol.test.js",
"test_integration_he_sharding": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/3-nodes ./node_modules/mocha/bin/mocha --timeout 640000 test/integration/he_sharding.test.js",
"test_integration_sharding": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/3-nodes ./node_modules/mocha/bin/mocha --timeout 640000 test/integration/sharding.test.js",
"test_unit": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ./node_modules/mocha/bin/mocha --timeout 160000 \"test/unit/*.test.js\"",
"test_unit_block_pool": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/block-pool.test.js",
"test_unit_blockchain": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/blockchain.test.js",
"test_unit_common_util": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/common-util.test.js",
"test_unit_consensus": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/consensus.test.js",
"test_unit_db": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/db.test.js",
"test_unit_event_handler": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/event-handler.test.js",
"test_unit_functions": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/functions.test.js",
"test_unit_object_util": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/object-util.test.js",
"test_unit_p2p": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node --timeout 320000 test/unit/p2p.test.js",
"test_unit_p2p_util": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node --timeout 160000 test/unit/p2p-util.test.js",
"test_unit_radix_node": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node --timeout 160000 test/unit/radix-node.test.js",
"test_unit_radix_tree": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node --timeout 160000 test/unit/radix-tree.test.js",
"test_unit_rule_util": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node --timeout 160000 test/unit/rule-util.test.js",
"test_unit_state_manager": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node --timeout 160000 test/unit/state-manager.test.js",
"test_unit_state_node": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node --timeout 160000 test/unit/state-node.test.js",
"test_unit_state_util": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node --timeout 160000 test/unit/state-util.test.js",
"test_unit_traffic_db": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node --timeout 160000 test/unit/traffic-database.test.js",
"test_unit_traffic_sm": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node --timeout 160000 test/unit/traffic-stats-manager.test.js",
"test_unit_tx": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/transaction.test.js",
"test_unit_tx_pool": "ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/tx-pool.test.js",
"test_unit": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 \"test/unit/*.test.js\"",
"test_unit_block_pool": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/block-pool.test.js",
"test_unit_blockchain": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/blockchain.test.js",
"test_unit_common_util": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/common-util.test.js",
"test_unit_consensus": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/consensus.test.js",
"test_unit_db": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/db.test.js",
"test_unit_event_handler": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/event-handler.test.js",
"test_unit_functions": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-nodeE NABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/functions.test.js",
"test_unit_object_util": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/object-util.test.js",
"test_unit_p2p": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 320000 test/unit/p2p.test.js",
"test_unit_p2p_util": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/p2p-util.test.js",
"test_unit_radix_node": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/radix-node.test.js",
"test_unit_radix_tree": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/radix-tree.test.js",
"test_unit_rule_util": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/rule-util.test.js",
"test_unit_state_manager": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/state-manager.test.js",
"test_unit_state_node": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/state-node.test.js",
"test_unit_state_util": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/state-util.test.js",
"test_unit_traffic_db": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/traffic-database.test.js",
"test_unit_traffic_sm": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/traffic-stats-manager.test.js",
"test_unit_tx": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/transaction.test.js",
"test_unit_tx_pool": "BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/1-node ENABLE_REST_FUNCTION_CALL=true UNSAFE_PRIVATE_KEY=b22c95ffc4a5c096f7d7d0487ba963ce6ac945bdc91c79b64ce209de289bec96 ./node_modules/mocha/bin/mocha --timeout 160000 test/unit/tx-pool.test.js",
"tracker": "npm run clean & node ./tracker-server/index.js"
},
"dependencies": {
Expand Down
52 changes: 26 additions & 26 deletions test/unit/state-util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,47 +352,47 @@ describe("state-util", () => {
})

it("when upper-case string input with blockNumber = 0 returning false", () => {
expect(isValidServiceName('A', 0)).to.equal(true);
expect(isValidServiceName('aA', 0)).to.equal(true);
expect(isValidServiceName('A_', 0)).to.equal(true);
expect(isValidServiceName('A0', 0)).to.equal(true);
expect(isValidServiceName('a0A', 0)).to.equal(true);
expect(isValidServiceName('A', 1)).to.equal(true);
expect(isValidServiceName('aA', 1)).to.equal(true);
expect(isValidServiceName('A_', 1)).to.equal(true);
expect(isValidServiceName('A0', 1)).to.equal(true);
expect(isValidServiceName('a0A', 1)).to.equal(true);
})

it("when upper-case string input with blockNumber = 1 returning false", () => {
expect(isValidServiceName('A', 1)).to.equal(false);
expect(isValidServiceName('aA', 1)).to.equal(false);
expect(isValidServiceName('A_', 1)).to.equal(false);
expect(isValidServiceName('A0', 1)).to.equal(false);
expect(isValidServiceName('a0A', 1)).to.equal(false);
expect(isValidServiceName('A', 2)).to.equal(false);
expect(isValidServiceName('aA', 2)).to.equal(false);
expect(isValidServiceName('A_', 2)).to.equal(false);
expect(isValidServiceName('A0', 2)).to.equal(false);
expect(isValidServiceName('a0A', 2)).to.equal(false);
})

it("when lower-case string input with blockNumber = 0 returning true", () => {
expect(isValidServiceName('a', 0)).to.equal(true);
expect(isValidServiceName('aa', 0)).to.equal(true);
expect(isValidServiceName('a_', 0)).to.equal(true);
expect(isValidServiceName('a0', 0)).to.equal(true);
expect(isValidServiceName('a0a', 0)).to.equal(true);
})

it("when lower-case string input with blockNumber = 1 returning true", () => {
expect(isValidServiceName('a', 1)).to.equal(true);
expect(isValidServiceName('aa', 1)).to.equal(true);
expect(isValidServiceName('a_', 1)).to.equal(true);
expect(isValidServiceName('a0', 1)).to.equal(true);
expect(isValidServiceName('a0a', 1)).to.equal(true);
expect(isValidServiceName('_', 1)).to.equal(true);
expect(isValidServiceName('_0', 1)).to.equal(true);
expect(isValidServiceName('_0_', 1)).to.equal(true);
expect(isValidServiceName('consensus', 1)).to.equal(true);
expect(isValidServiceName('afan', 1)).to.equal(true);
expect(isValidServiceName('collaborative_ai', 1)).to.equal(true);
expect(isValidServiceName('_a_dapp', 1)).to.equal(true);
})

it("when lower-case string input with blockNumber = 1 returning true", () => {
expect(isValidServiceName('a', 2)).to.equal(true);
expect(isValidServiceName('aa', 2)).to.equal(true);
expect(isValidServiceName('a_', 2)).to.equal(true);
expect(isValidServiceName('a0', 2)).to.equal(true);
expect(isValidServiceName('a0a', 2)).to.equal(true);
expect(isValidServiceName('_', 2)).to.equal(true);
expect(isValidServiceName('_0', 2)).to.equal(true);
expect(isValidServiceName('_0_', 2)).to.equal(true);
expect(isValidServiceName('consensus', 2)).to.equal(true);
expect(isValidServiceName('afan', 2)).to.equal(true);
expect(isValidServiceName('collaborative_ai', 2)).to.equal(true);
expect(isValidServiceName('_a_dapp', 2)).to.equal(true);
})

it("when reserved service name input returning false", () => {
expect(isValidServiceName('balance_total_sum', 0)).to.equal(false);
expect(isValidServiceName('balance_total_sum', 1)).to.equal(false);
expect(isValidServiceName('balance_total_sum', 2)).to.equal(false);
})
})

Expand Down

0 comments on commit 3a1ceaa

Please sign in to comment.