Skip to content

Commit

Permalink
run nucleus docker image
Browse files Browse the repository at this point in the history
Signed-off-by: onur-ozkan <work@onurozkan.dev>
  • Loading branch information
onur-ozkan committed May 29, 2024
1 parent 9ee35e4 commit 6a8acb7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
25 changes: 25 additions & 0 deletions mm2src/mm2_main/tests/docker_tests/docker_tests_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ pub const UTXO_ASSET_DOCKER_IMAGE_WITH_TAG: &str = "docker.io/artempikulin/testb
pub const GETH_DOCKER_IMAGE: &str = "docker.io/ethereum/client-go";
pub const GETH_DOCKER_IMAGE_WITH_TAG: &str = "docker.io/ethereum/client-go:stable";

pub const NUCLEUS_IMAGE: &str = "docker.io/komodoofficial/nucleusd";

pub const QTUM_ADDRESS_LABEL: &str = "MM2_ADDRESS_LABEL";

/// ERC721_TEST_TOKEN has additional mint function
Expand Down Expand Up @@ -347,6 +349,29 @@ pub fn geth_docker_node<'a>(docker: &'a Cli, ticker: &'static str, port: u16) ->
}
}

pub fn nucleus_node<'a>(docker: &'a Cli, port: u16) -> DockerNode<'a> {
let nucleus_node_state_dir = {
let mut current_dir = std::env::current_dir().unwrap();
current_dir.pop();
current_dir.pop();
current_dir.join(".docker/container-state/nucleus-testnet-data")
};
assert!(nucleus_node_state_dir.exists());

let image = GenericImage::new(NUCLEUS_IMAGE, "latest")
.with_volume(nucleus_node_state_dir.to_str().unwrap(), "/root/.nucleus");
let args = vec!["--dev".into(), "--http".into(), "--http.addr=0.0.0.0".into()];
let image = RunnableImage::from((image, args))
.with_mapped_port((port, port));
let container = docker.run(image);

DockerNode {
container,
ticker: Default::default(),
port,
}
}

pub fn rmd160_from_priv(privkey: Secp256k1Secret) -> H160 {
let secret = SecretKey::from_slice(privkey.as_slice()).unwrap();
let public = PublicKey::from_secret_key(&Secp256k1::new(), &secret);
Expand Down
13 changes: 9 additions & 4 deletions mm2src/mm2_main/tests/docker_tests/tendermint_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const ATOM_TEST_WITHDRAW_SEED: &str = "atom test withdraw seed";
const ATOM_TICKER: &str = "ATOM";
const ATOM_TENDERMINT_RPC_URLS: &[&str] = &["https://rpc.sentry-02.theta-testnet.polypore.xyz"];

const IRIS_TEST_SEED: &str = "iris test seed";
const TENDERMINT_TEST_SEED: &str = "tendermint test seed";
const IRIS_TESTNET_RPC_URLS: &[&str] = &["http://34.80.202.172:26657"];

const NUCLEUS_TESTNET_RPC_URLS: &[&str] = &["http://5.161.55.53:26657"];
const NUCLEUS_TESTNET_RPC_URLS: &[&str] = &["http://0.0.0.0:26657"];

const TENDERMINT_TEST_BIP39_SEED: &str =
"emerge canoe salmon dolphin glow priority random become gasp sell blade argue";
Expand Down Expand Up @@ -271,7 +271,7 @@ fn test_tendermint_token_ibc_withdraw() {
let platform_coin = coins[0]["coin"].as_str().unwrap();
let token = coins[1]["coin"].as_str().unwrap();

let conf = Mm2TestConf::seednode(IRIS_TEST_SEED, &coins);
let conf = Mm2TestConf::seednode(TENDERMINT_TEST_SEED, &coins);
let mm = MarketMakerIt::start(conf.conf, conf.rpc_password, None).unwrap();

let activation_res = block_on(enable_tendermint(&mm, platform_coin, &[], IRIS_TESTNET_RPC_URLS, false));
Expand Down Expand Up @@ -356,14 +356,15 @@ fn test_tendermint_ibc_withdraw_hd() {
}

#[test]
#[ignore]
fn test_tendermint_token_withdraw() {
const MY_ADDRESS: &str = "iaa1e0rx87mdj79zejewuc4jg7ql9ud2286g2us8f2";

let coins = json!([iris_testnet_conf(), iris_nimda_testnet_conf()]);
let platform_coin = coins[0]["coin"].as_str().unwrap();
let token = coins[1]["coin"].as_str().unwrap();

let conf = Mm2TestConf::seednode(IRIS_TEST_SEED, &coins);
let conf = Mm2TestConf::seednode(TENDERMINT_TEST_SEED, &coins);
let mm = MarketMakerIt::start(conf.conf, conf.rpc_password, None).unwrap();

let activation_res = block_on(enable_tendermint(&mm, platform_coin, &[], IRIS_TESTNET_RPC_URLS, false));
Expand Down Expand Up @@ -430,6 +431,7 @@ fn test_tendermint_token_withdraw() {
}

#[test]
#[ignore]
fn test_tendermint_tx_history() {
const TEST_SEED: &str = "Vdo8Xt8pTAetRlMq3kV0LzE393eVYbPSn5Mhtw4p";
const TX_FINISHED_LOG: &str = "Tx history fetching finished for IRIS-TEST.";
Expand Down Expand Up @@ -505,6 +507,7 @@ fn test_tendermint_tx_history() {
}

#[test]
#[ignore]
fn test_disable_tendermint_platform_coin_with_token() {
const TEST_SEED: &str = "iris test seed";
let coins = json!([iris_testnet_conf(), iris_nimda_testnet_conf()]);
Expand Down Expand Up @@ -536,6 +539,7 @@ fn test_disable_tendermint_platform_coin_with_token() {
}

#[test]
#[ignore]
fn test_passive_coin_and_force_disable() {
const TEST_SEED: &str = "iris test seed";
let coins = json!([iris_testnet_conf(), iris_nimda_testnet_conf()]);
Expand Down Expand Up @@ -602,6 +606,7 @@ mod swap {
const TBNB_SWAP_CONTRACT: &str = "0xB1Ad803ea4F57401639c123000C75F5B66E4D123";

#[test]
#[ignore]
fn swap_usdc_ibc_with_nimda() {
let bob_passphrase = String::from(BOB_PASSPHRASE);
let alice_passphrase = String::from(ALICE_PASSPHRASE);
Expand Down
3 changes: 3 additions & 0 deletions mm2src/mm2_main/tests/docker_tests_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,18 @@ pub fn docker_tests_runner(tests: &[&TestDescAndFn]) {
pull_docker_image(UTXO_ASSET_DOCKER_IMAGE_WITH_TAG);
pull_docker_image(QTUM_REGTEST_DOCKER_IMAGE_WITH_TAG);
pull_docker_image(GETH_DOCKER_IMAGE_WITH_TAG);
pull_docker_image(NUCLEUS_IMAGE);
remove_docker_containers(UTXO_ASSET_DOCKER_IMAGE_WITH_TAG);
remove_docker_containers(QTUM_REGTEST_DOCKER_IMAGE_WITH_TAG);
remove_docker_containers(GETH_DOCKER_IMAGE_WITH_TAG);
remove_docker_containers(NUCLEUS_IMAGE);

let utxo_node = utxo_asset_docker_node(&docker, "MYCOIN", 7000);
let utxo_node1 = utxo_asset_docker_node(&docker, "MYCOIN1", 8000);
let qtum_node = qtum_docker_node(&docker, 9000);
let for_slp_node = utxo_asset_docker_node(&docker, "FORSLP", 10000);
let geth_node = geth_docker_node(&docker, "ETH", 8545);
let nucleus_node = nucleus_node(&docker, 26657);

let utxo_ops = UtxoAssetDockerOps::from_ticker("MYCOIN");
let utxo_ops1 = UtxoAssetDockerOps::from_ticker("MYCOIN1");
Expand Down

0 comments on commit 6a8acb7

Please sign in to comment.