Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
update tests and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
aemil145 committed Apr 7, 2022
1 parent b5f51a5 commit 2603c81
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 38 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ By using this tool you can also spin up a local [`Cudos node`](https://github.co
* [Available functions in global context](#available-functions-in-global-context)
* [Exposed functions of a contract instance](#exposed-functions-of-a-contract-instance)
* [Network](#network)
* [Localhost](#localhost)
* [Testnet](#testnet)
* [Mainnet](#mainnet)
* [Managing accounts](#managing-accounts)
Expand Down Expand Up @@ -292,8 +293,14 @@ blast run scripts/myCustomScript.js -n testnet
---
## Network
You can connect to a default local node as well as a public one or you can use your own Cudos node. One way to do that is to add a `{custom_name}: {node_url}` to `networks` field in `blast.config.js`, then call the run command with `--network` or `-n` followed by `{custom_name}`. You can set `defaultNetwork: {custom_name}` in the config to connect to that node automatically. If there is no `defaultNetwork`, run command uses `localNetwork` to connect to the default local node.
Here are public Cudos nodes you can use to connect to Cudos network:
You can connect to the default local node as well as a public one or you can use your own Cudos node. To do that, add a `{custom_name}: {node_url}` to `networks` field in `blast.config.js`, then call the run command with `--network` or `-n` followed by `{custom_name}`. If no network is passed, blast commands connect to the default local node.
Here are Cudos nodes you can use to connect to Cudos network:
### Localhost
| Chain ID | URL |
| --- | --- |
| cudos-network | http://localhost:26657 |
### Testnet
Expand Down
23 changes: 12 additions & 11 deletions packages/blast-tests/e2e-tests/tests/compile-run.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ else
echo -e $PASSED
fi

echo -n 'blast run -n [network]...'
# Set [defaultNetwork] to invalid value and add the local network to [networks] to ensure that the passing tests will
# ignore [defaultNetwork]
sed -i '' $'s|defaultNetwork: \'\'|defaultNetwork: \'https://an-inhospitable-node.cudos.org:26657\'|' blast.config.js
sed -i '' $'s|networks: {|networks: {\tlocalhost_test: \'http://localhost:26657\',|' blast.config.js

if [[ ! `blast run ./scripts/deploy.js -n localhost_test` =~ 'cudos' ]]; then
echo -e $FAILED
exit_status=1
else
echo -e $PASSED
# executing blast run on local network through --network only if normal run is passing
if [[ $exit_status != 1 ]]; then
echo -n 'blast run -n [network]...'
# Add localhost to [networks] in the config
sed -i '' $'s|networks: {|networks: {\tlocalhost_test: \'http://localhost:26657\',|' blast.config.js

if [[ ! `blast run ./scripts/deploy.js -n localhost_test` =~ 'cudos' ]]; then
echo -e $FAILED
exit_status=1
else
echo -e $PASSED
fi
fi

rm -r ../$init_folder &> /dev/null || true
Expand Down
35 changes: 25 additions & 10 deletions packages/blast-tests/e2e-tests/tests/node-start-status.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,32 @@ else
echo -e $PASSED
fi

echo -n 'blast node status -n [network]...'
# Set [defaultNetwork] to invalid value and add the local network to [networks] to ensure that the passing tests will
# ignore [defaultNetwork]
sed -i '' $'s|defaultNetwork: \'\'|defaultNetwork: \'https://an-inhospitable-node.cudos.org:26657\'|' blast.config.js
sed -i '' $'s|networks: {|networks: {\tlocalhost_test: \'http://localhost:26657\',|' blast.config.js
# executing node status on local network through --network only if test normal status is passing
if [[ $exit_status != 1 ]]; then
echo -n 'blast node status -n [network]...'
# Add localhost to [networks] in the config
sed -i '' $'s|networks: {|networks: {\tlocalhost_test: \'http://localhost:26657\',|' blast.config.js

if [[ ! `blast node status -n localhost_test` =~ 'online' ]]; then
echo -e $FAILED
exit_status=1
else
echo -e $PASSED
if [[ ! `blast node status -n localhost_test` =~ 'online' ]]; then
echo -e $FAILED
exit_status=1
else
echo -e $PASSED
fi
fi

# make sure the local network is considered through --network by failing the status on invalid url
if [[ $exit_status != 1 ]]; then
echo -n 'blast node status -n [invalid_network]...'
# Add invalid localhost to [networks] in the config
sed -i '' $'s|networks: {|networks: {\tinvalid_localhost_test: \'http://non-existent-localhost:26657\', |' blast.config.js

if [[ `blast node status -n invalid_localhost_test` =~ 'online' ]]; then
echo -e $FAILED
exit_status=1
else
echo -e $PASSED
fi
fi

rm -r ../$init_folder &> /dev/null || true
Expand Down
25 changes: 13 additions & 12 deletions packages/blast-tests/e2e-tests/tests/test.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@ else
echo -e $PASSED
fi

echo -n 'blast test -n [network]...'
# Set [defaultNetwork] to invalid value and add the local network to [networks] to ensure that the passing tests will
# ignore [defaultNetwork]
sed -i '' $'s|defaultNetwork: \'\'|defaultNetwork: \'https://an-inhospitable-node.cudos.org:26657\'|' blast.config.js
sed -i '' $'s|networks: {|networks: {\tlocalhost_test: \'http://localhost:26657\',|' blast.config.js
# executing blast test on local network through --network only if tests are passing
if [[ $exit_status != 1 ]]; then
echo -n 'blast test -n [network]...'
# Add localhost to [networks] in the config
sed -i '' $'s|networks: {|networks: {\tlocalhost_test: \'http://localhost:26657\',|' blast.config.js

blast test -n localhost_test &> jest.logs.json
result=`cat jest.logs.json`
if [[ ! $result =~ $TEST_RESULT ]]; then
echo -e "$FAILED\n$EXPECTED\n$TEST_RESULT\n$ACTUAL\n$result" 1>&2
exit_status=1
else
echo -e $PASSED
blast test -n localhost_test &> jest.logs.json
result=`cat jest.logs.json`
if [[ ! $result =~ $TEST_RESULT ]]; then
echo -e "$FAILED\n$EXPECTED\n$TEST_RESULT\n$ACTUAL\n$result" 1>&2
exit_status=1
else
echo -e $PASSED
fi
fi

rm -r ../$init_folder &> /dev/null || true
Expand Down
1 change: 0 additions & 1 deletion template/blast.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports.config = {
// optional parameners
additionalAccounts: 0,
customAccountBalances: 1000000000000000000,
defaultNetwork: '',
networks: {
testnet: 'https://sentry1.gcp-uscentral1.cudos.org:36657'
}
Expand Down
4 changes: 2 additions & 2 deletions template/tests/alpha.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ describe('alpha contract', () => {

beforeAll(async () => {
[alice, bob] = await getSigners()
contract = await getContractFactory('alpha')
await contract.deploy(MSG_INIT, bob)
contract = await getContractFactory('alpha', bob)
await contract.deploy(MSG_INIT)
})

test('increment count', async () => {
Expand Down

0 comments on commit 2603c81

Please sign in to comment.