Skip to content

Commit

Permalink
refactor: sync with axon new start commands
Browse files Browse the repository at this point in the history
  • Loading branch information
wenyuanhust committed Sep 26, 2023
1 parent 4205215 commit 23394d3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ibc-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
timeout-minutes: 60
env:
SRC_DIR: ${{ github.workspace }}/ibc-test-src
AXON_COMMIT: d03d2bb7cb3dcdc03319c3a74beeee6715e7f448
AXON_COMMIT: 51179a38be36d3f13884ba4cd804cc9276c7b72c
IBC_CONTRACT_COMMIT: 5746d048304ca4d73dc4800459ddd79d57fa124c
strategy:
fail-fast: false
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ $ yarn migrate > migrate.log | tail -f migrate.log
After running `yarn migrate`, the `OwnableIBCHandler` address is listing in console, we record it and mark as **`YOUR_IBC_AXON_ADDRESS`** to use later.

### Contract Deployment on CKB
Detailed deployment steps can be found in [ibc-ckb-contracts](https://github.com/synapseweb3/ibc-ckb-contracts). Alternatively, you can find pre-deployed contracts TYPE_ARGS on both testnet and mainnet:
Detailed deployment steps can be found in [forcerelay-ckb-contracts](https://github.com/synapseweb3/forcerelay-ckb-contracts). Alternatively, you can find pre-deployed contracts TYPE_ARGS on both testnet and mainnet:
||Mainnet|Testnet|
|-|-|-|
|connection|WIP|WIP|
Expand All @@ -58,7 +58,7 @@ Unlike Axon, business modules cannot be registered directly with a contract on C
It's important to note that the IBC port on CKB corresponds to the `LOCK_HASH` of your wallet cell on CKB, which we will refer to as `WALLET_LOCK_HASH` for future use.

### Installation and Setting
We recommand you to download the pre-compiled binary, or you can compile mannully from the source code, which requires `Rust ^v1.72.0` installed:
We recommend you to download the pre-compiled binary, or you can compile mannully from the source code, which requires `Rust ^v1.72.0` installed:

```
$ git clone https://github.com/synapseweb3/forcerelay
Expand Down
2 changes: 1 addition & 1 deletion tools/ibc-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Environment variables:

``` bash
# IBC contracts
export IBC_CONTRACTS_SRC_PATH = <ibc solidity contract source path>
export IBC_CONTRACTS_SRC_PATH=<ibc solidity contract source path>
cd $IBC_CONTRACTS_SRC_PATH && yarn install && yarn compile

# Axon
Expand Down
43 changes: 36 additions & 7 deletions tools/ibc-test/src/framework/utils/axon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,27 @@ pub(crate) fn prepare_axon_chain(
working_dir.push(dir_path);
let _ = std::fs::remove_dir_all(dir_path);
std::fs::create_dir_all(dir_path).with_context(|| format!("create_dir {:?}", dir_path))?;
let binding = working_dir.join("devtools/chain/specs/single_node");
let chain_spec_dir_path = binding.to_str().unwrap();
std::fs::create_dir_all(chain_spec_dir_path)
.with_context(|| format!("create_chain_spec_dir {:?}", chain_spec_dir_path))?;

// copy configs to working dir
for file in [
"config.toml",
"genesis_single_node.json",
"specs/single_node/chain-spec.toml",
"specs/single_node/genesis_transactions.json",
"debug.key",
"default.db-options",
] {
let src_path = axon_src_path.join("devtools/chain").join(file);
std::fs::copy(&src_path, working_dir.join(file))
std::fs::copy(&src_path, working_dir.join("devtools/chain").join(file))
.with_context(|| format!("cp {:?} -> {:?}", &src_path, working_dir.join(file)))?;
}

let chain_config_path = working_dir.join("config.toml");
let genesis_config_path = working_dir.join("genesis_single_node.json");
let chain_config_path = working_dir.join("devtools/chain").join("config.toml");
let chain_spec_path = working_dir.join("devtools/chain").join("specs/single_node/chain-spec.toml");
let key_file_path = working_dir.join("devtools/chain").join("debug.key");

// Modify configs

Expand Down Expand Up @@ -94,14 +101,26 @@ pub(crate) fn prepare_axon_chain(
fs::write(&chain_config_path, config_doc.to_string())
.with_context(|| format!("write config to {:?}", &chain_config_path))?;

// init axon
let _init_command = Command::new("axon")
.arg("init")
.arg("--config")
.arg(&chain_config_path)
.arg("--chain-spec")
.arg(&chain_spec_path)
.arg("--key-file")
.arg(&key_file_path)
.current_dir(&working_dir)
// .stdout(Stdio::null())
// .stderr(Stdio::null())
.output()?;

// start process
let chain_process = ChildProcess::new(
Command::new("axon")
.arg("run")
.arg("-c")
.arg("--config")
.arg(&chain_config_path)
.arg("-g")
.arg(&genesis_config_path)
.current_dir(&working_dir)
.stdout(Stdio::null())
.stderr(Stdio::null())
Expand Down Expand Up @@ -144,6 +163,16 @@ pub(crate) fn prepare_axon_chain(
Ok(chain_process)
}

#[test]
fn test_command() {
let init_command = Command::new("ls")
// .stdout(Stdio::null())
// .stderr(Stdio::null())
.output()
.expect("axon init fail");
println!("{:?}", init_command);
}

fn check_command_output(output: &Output, working_dir: &Path) -> Result<()> {
if !output.status.success() {
let log_path = working_dir.join("deploy.log");
Expand Down

0 comments on commit 23394d3

Please sign in to comment.