Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scripts): generalize error handling in utils.setConfig #20

Merged
merged 9 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ jobs:

- name: Download and Install Sui Binary
run: |
wget https://github.com/MystenLabs/sui/releases/download/mainnet-v1.19.1/sui-mainnet-v1.19.1-ubuntu-x86_64.tgz
tar -xvf sui-mainnet-v1.19.1-ubuntu-x86_64.tgz
wget https://github.com/MystenLabs/sui/releases/download/mainnet-v1.22.0/sui-mainnet-v1.22.0-ubuntu-x86_64.tgz
tar -xvf sui-mainnet-v1.22.0-ubuntu-x86_64.tgz
sudo mv ./target/release/sui-test-validator-ubuntu-x86_64 /usr/local/bin/sui-test-validator
sudo mv ./target/release/sui-ubuntu-x86_64 /usr/local/bin/sui

- name: Cleanup
run: rm -rf sui-mainnet-v1.19.1-ubuntu-x86_64.tgz
run: rm -rf sui-mainnet-v1.22.0-ubuntu-x86_64.tgz

- name: Setup Node
uses: actions/setup-node@v3
Expand Down
1 change: 0 additions & 1 deletion move/abi/sources/abi.move
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module abi::abi {
use std::vector;

public struct AbiReader has copy, drop {
bytes: vector<u8>,
Expand Down
12 changes: 7 additions & 5 deletions move/its/sources/discovery.move
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ module its::discovery {

let type_arg = std::type_name::get<RelayerDiscovery>();
its.test_add_registered_coin_type(its::token_id::from_address(token_id), type_arg);
let call_info = get_call_info(&its, payload);
assert!(get_call_info(&its, payload) == get_interchain_transfer_tx(&its, &abi::new_reader(payload)), 1);
let mut tx_block = get_call_info(&its, payload);
assert!(tx_block == vector[get_interchain_transfer_tx(&its, &abi::new_reader(payload))], 1);
let call_info = vector::pop_back(&mut tx_block);

assert!(call_info.function().package_id() == its_package_id(), 2);
assert!(call_info.function().module_name() == ascii::string(b"service"), 3);
Expand Down Expand Up @@ -235,7 +236,7 @@ module its::discovery {
let payload = writer.into_bytes();

its.test_add_registered_coin_type(its::token_id::from_address(token_id), std::type_name::get<RelayerDiscovery>());
assert!(get_call_info(&its, payload) == get_interchain_transfer_tx(&its, &abi::new_reader(payload)), 1);
assert!(get_call_info(&its, payload) == vector[get_interchain_transfer_tx(&its, &abi::new_reader(payload))], 1);

sui::test_utils::destroy(its);
sui::test_utils::destroy(discovery);
Expand Down Expand Up @@ -266,9 +267,10 @@ module its::discovery {

let type_arg = std::type_name::get<RelayerDiscovery>();
its.test_add_unregistered_coin_type(its::token_id::unregistered_token_id(&ascii::string(symbol), (decimals as u8)), type_arg);
let call_info = get_call_info(&its, payload);
assert!(get_call_info(&its, payload) == get_deploy_interchain_token_tx(&its, &abi::new_reader(payload)), 1);
let mut tx_block = get_call_info(&its, payload);
assert!(tx_block == vector[get_deploy_interchain_token_tx(&its, &abi::new_reader(payload))], 1);

let call_info = vector::pop_back(&mut tx_block);
assert!(call_info.function().package_id() == its_package_id(), 2);
assert!(call_info.function().module_name() == ascii::string(b"service"), 3);
assert!(call_info.function().name() == ascii::string(b"receive_deploy_interchain_token"), 4);
Expand Down
3 changes: 0 additions & 3 deletions move/its/tests/coin_init_test.move
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#[test_only]
module its::thecool1234coin___ {
use sui::tx_context::{Self, TxContext};
use sui::coin;
use std::option;
use sui::url::{Url};
use sui::transfer;

public struct THECOOL1234COIN___ has drop{

Expand Down
13 changes: 12 additions & 1 deletion scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,18 @@ function getConfig(packagePath, envAlias) {

function setConfig(packagePath, envAlias, config) {
if(!configs[packagePath]) {
configs[packagePath] = fs.existsSync(`${__dirname}/../info/${packagePath}.json`) ? require(`${__dirname}/../info/${packagePath}.json`) : {};
try {
configs[packagePath] = require(`${__dirname}/../info/${packagePath}.json`);
} catch(e) {
switch (e.code) {
case 'MODULE_NOT_FOUND':
case undefined:
configs[packagePath] = {};
break;
default:
throw e;
}
}
}
configs[packagePath][envAlias] = config;

Expand Down
Loading