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

test(solana): migrate to local/offline containerized node #2187

Closed
wants to merge 24 commits into from

Conversation

mj-blockydevs
Copy link

No description provided.

…cal node. Non-dockerised tests (out of solana - scope) excluded.

Signed-off-by: Mariusz Jasuwienas <[email protected]>
@mj-blockydevs mj-blockydevs changed the title DRAFT - testing pipelines feat(solana-dockerised-tests) testing pipelines Aug 6, 2024
@mj-blockydevs mj-blockydevs marked this pull request as ready for review August 6, 2024 13:56
@shamardy shamardy changed the title feat(solana-dockerised-tests) testing pipelines test(solana): migrate to local/offline containerized node Aug 6, 2024
@shamardy shamardy requested review from shamardy and laruh August 7, 2024 01:10
mm2src/mm2_main/tests/docker_tests/docker_tests_common.rs Outdated Show resolved Hide resolved
Comment on lines 1111 to 1123
fn find_container_id_by_port(port: u16) -> Option<String> {
let output = Command::new("docker")
.args(["ps", "--filter", &format!("publish={}", port), "--format", "{{.ID}}"])
.output()
.expect("failed to execute docker ps");

let container_id = str::from_utf8(&output.stdout).ok()?.trim().to_string();
if container_id.is_empty() {
None
} else {
Some(container_id)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify why is this needed? Once the container is started we have DockerNode type that contains the container informations.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It technically is not. We could pass the DockerNode variable here.

Comment on lines 146 to 182
#[test]
#[cfg(not(target_arch = "wasm32"))]
fn solana_keypair_from_secp_dockerized() { solana_keypair_from_secp(); }

#[test]
#[cfg(not(target_arch = "wasm32"))]
fn solana_transaction_simulations_dockerized() { solana_transaction_simulations(); }

#[test]
#[cfg(not(target_arch = "wasm32"))]
fn solana_transaction_zero_balance_dockerized() { solana_transaction_zero_balance(); }

#[test]
#[cfg(not(target_arch = "wasm32"))]
fn solana_transaction_simulations_not_enough_for_fees_dockerized() {
solana_transaction_simulations_not_enough_for_fees();
}

#[test]
#[cfg(not(target_arch = "wasm32"))]
fn solana_transaction_simulations_max_dockerized() { solana_transaction_simulations_not_enough_for_fees(); }

#[test]
#[cfg(not(target_arch = "wasm32"))]
fn solana_test_transactions_dockerized() { solana_test_transactions(); }

// This test is just a unit test for brainstorming around tx_history for base_coin.
#[test]
#[ignore]
#[cfg(not(target_arch = "wasm32"))]
fn solana_test_tx_history_dockerized() { solana_test_transactions(); }

#[test]
fn solana_coin_send_and_refund_maker_payment_dockerized() { solana_coin_send_and_refund_maker_payment(); }

#[test]
fn solana_coin_send_and_spend_maker_payment_dockerized() { solana_coin_send_and_spend_maker_payment(); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to move those tests here instead of wrapping them with this functions?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, @onur-ozkan I've moved the tests here, as you asked.

@@ -113,7 +115,7 @@ pub const GETH_DOCKER_IMAGE_WITH_TAG: &str = "docker.io/ethereum/client-go:stabl
pub const NUCLEUS_IMAGE: &str = "docker.io/komodoofficial/nucleusd";
pub const ATOM_IMAGE: &str = "docker.io/komodoofficial/gaiad";
pub const IBC_RELAYER_IMAGE: &str = "docker.io/komodoofficial/ibc-relayer";

pub const SOLANA_CLUSTER_DOCKER_IMAGE: &str = "docker.io/0xbdj/solana-node-test";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to push this image under https://hub.docker.com/u/komodoofficial org.

Copy link
Author

@mj-blockydevs mj-blockydevs Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is a good idea. However, I'll complete this PR first to ensure that the expected final version is pushed there.

Copy link
Member

@laruh laruh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your work!
I have one comment for now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be move solana_tests and solana_common_tests files to /mm2_main/tests/mm2_tests?
It looks like there is too much test code in mm2src space

Copy link
Collaborator

@shamardy shamardy Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's similar to this comment #2187 (comment)
They should be moved to mm2_main/tests/docker_tests/solana_tests.rs, spl_tests should also be moved to a new spl_tests.rs file in docker tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, can you check it now, please @shamardy ?

Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, we are moving in the right direction! Only one note from me for now as @onur-ozkan and @laruh covered my other note about moving tests.

spl-token mint "$USDC_TOKEN" 100000
spl-token mint "$ADEX_TOKEN" 100000
# Iterate over each account file in the directory
for ACCOUNT_FILE in "$ACCOUNTS_DIR"/*.json; do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with having multiple accounts for users created and funded while starting the docker node, but this will cause problems for you in the future while implementing HD wallet since there are multiple addresses/accounts per HD wallet and you will need to update the docker image for those tests. A better pattern is to have one distributor account and this sends coins/tokens to addresses at the start of each test similar to how it's done for ethereum and other coins that use dockerized nodes

pub fn fill_eth(to_addr: Address, amount: U256) {

fn fill_erc20(to_addr: Address, amount: U256) {

It's up to you if you want to handle this now or later, but handling it here is the right choice so we don't change the docker image again ref. #2187 (comment)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shamardy, all the tests are now working correctly with SPL tokens minted to a single account (I've updated the mint.sh file as you suggested). I believe we can introduce the "filling" methods later, as they are primarily needed to cover the currently implemented test case scenarios.

Copy link
Member

@laruh laruh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fixes, next iteration

let invalid_tx_details = block_on(
sol_coin
.withdraw(WithdrawRequest::new(
"SOL".to_string(),
Copy link
Member

@laruh laruh Aug 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It worth creating const SOL: &str = "SOL"; if there are string repetitions

#[test]
#[cfg(not(target_arch = "wasm32"))]
fn solana_transaction_simulations_not_enough_for_fees_dockerized() {
let passphrase = "non existent passphrase".to_string();
Copy link
Member

@laruh laruh Aug 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for "fake passphrase" / "non existent passphrase" strings, you can create one const and reuse it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@laruh I've refactored the code to move all the repeated strings into constants. However, I'm concerned that this might have gone a bit too far (especially in test case scenarios). I feel it may have impacted readability in some areas. Let me know if you think we should adjust this or leave it as it is right now.

Copy link
Member

@laruh laruh Aug 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned that this might have gone a bit too far

Yeah, some consts are used just once
Screenshot 2024-08-10 at 09 41 08

It was basically enough to add consts for strings mentioned in review comments
Screenshot 2024-08-10 at 09 42 14

In spl_tests.rs you leave one const USDC: &str = "USDC";

In solana_common_tests consts are fine, just it would be better to rename PASSPHRASE to SOL_PASSPHRASE to note that its for solana, same for ADDITIONAL_PASSPHRASE -> SOL_ADDITIONAL_PASSPHRASE

pub const PASSPHRASE: &str = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron";
pub const ADDITIONAL_PASSPHRASE: &str =

@mj-blockydevs please when you answer in the review that something was fixed, provide commit link/links to this fix.
Like in this example #2169 (comment) and below.
This way makes review process a lot easier for all sides, especially when we have notes from different reviewers and various fix commits.

#[test]
#[cfg(not(target_arch = "wasm32"))]
fn solana_test_transactions_dockerized() {
let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also provide it as const

fn solana_coin_send_and_refund_maker_payment_dockerized() {
let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string();
let (_, coin) = solana_coin_for_test(passphrase, SolanaNet::Local);
let solana_program_id = "GCJUXKH4VeKzEtr9YgwaNWC3dJonFgsM3yMiBa64CZ8m";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"GCJUXKH4VeKzEtr9YgwaNWC3dJonFgsM3yMiBa64CZ8m" also can be used as const

Comment on lines 235 to 243
pub struct SolanaCoinImpl {
ticker: String,
key_pair: SolKeypair,
pub key_pair: SolKeypair,
client: RpcClient,
decimals: u8,
my_address: String,
pub my_address: String,
spl_tokens_infos: Arc<Mutex<HashMap<String, SplTokenInfo>>>,
/// This spawner is used to spawn coin's related futures that should be aborted on coin deactivation
/// and on [`MmArc::stop`].
Copy link
Member

@laruh laruh Aug 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need to make these fields (plus abortable) pub?
I could pass clippy warnings check making them private
Screenshot 2024-08-08 at 14 04 00

also amount_to_ui_amount function is never used. I think it could be useful in the future, please add dead code annotation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@laruh, yes, I was able to access the data using the existing methods, so there's no need to make them public.

Comment on lines +67 to +68
pub use solana_client;
pub use solana_sdk;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to make these mods and consts pub
Screenshot 2024-08-08 at 14 12 18

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@laruh, I tried to access them from the Docker-related test crate, so I needed to expose them.

By the way, what kind of Clippy response is that? I can't seem to reproduce it. Could you provide some guidance on how to achieve that?

/komodo-defi-framework/: cargo clippy --all-targets --all-features -- -D warnings
warning: /komodo-defi-framework/mm2src/mm2_bin_lib/Cargo.toml: file `/komodo-defi-framework/mm2src/mm2_bin_lib/src/mm2_bin.rs` found to be present in multiple build targets:
  * `bin` target `mm2`
  * `bin` target `kdf`
   Compiling common v0.1.0 (/komodo-defi-framework/mm2src/common)
   Compiling ser_error v0.1.0 (/komodo-defi-framework/mm2src/derives/ser_error)
    Checking shared_ref_counter v0.1.0 (/komodo-defi-framework/mm2src/common/shared_ref_counter)
    Checking primitives v0.1.0 (/komodo-defi-framework/mm2src/mm2_bitcoin/primitives)
    Checking test_helpers v0.1.0 (/komodo-defi-framework/mm2src/mm2_bitcoin/test_helpers)
   Compiling serialization_derive v0.1.0 (/komodo-defi-framework/mm2src/mm2_bitcoin/serialization_derive)
   Compiling trezor v0.1.1 (/komodo-defi-framework/mm2src/trezor)
   Compiling enum_derives v0.1.0 (/komodo-defi-framework/mm2src/derives/enum_derives)
    Checking mm2_number v0.1.0 (/komodo-defi-framework/mm2src/mm2_number)
    Checking serialization v0.1.0 (/komodo-defi-framework/mm2src/mm2_bitcoin/serialization)
   Compiling ser_error_derive v0.1.0 (/komodo-defi-framework/mm2src/derives/ser_error_derive)
   Compiling coins v0.1.0 (/komodo-defi-framework/mm2src/coins)
    Checking bitcrypto v0.1.0 (/komodo-defi-framework/mm2src/mm2_bitcoin/crypto)
    Checking mm2_state_machine v0.1.0 (/komodo-defi-framework/mm2src/mm2_state_machine)
    Checking keys v0.1.0 (/komodo-defi-framework/mm2src/mm2_bitcoin/keys)
   Compiling mm2_main v0.1.0 (/komodo-defi-framework/mm2src/mm2_main)
   Compiling mm2_bin_lib v2.1.0-beta (/komodo-defi-framework/mm2src/mm2_bin_lib)
    Checking chain v0.1.0 (/komodo-defi-framework/mm2src/mm2_bitcoin/chain)
    Checking script v0.1.0 (/komodo-defi-framework/mm2src/mm2_bitcoin/script)
    Checking spv_validation v0.1.0 (/komodo-defi-framework/mm2src/mm2_bitcoin/spv_validation)
    Checking rpc v0.1.0 (/komodo-defi-framework/mm2src/mm2_bitcoin/rpc)
    Checking mm2_metamask v0.1.0 (/komodo-defi-framework/mm2src/mm2_metamask)
    Checking mm2_db v0.1.0 (/komodo-defi-framework/mm2src/mm2_db)
    Checking mm2_err_handle v0.1.0 (/komodo-defi-framework/mm2src/mm2_err_handle)
    Checking mm2_event_stream v0.1.0 (/komodo-defi-framework/mm2src/mm2_event_stream)
    Checking db_common v0.1.0 (/komodo-defi-framework/mm2src/db_common)
    Checking mm2_p2p v0.1.0 (/komodo-defi-framework/mm2src/mm2_p2p)
    Checking mm2_metrics v0.1.0 (/komodo-defi-framework/mm2src/mm2_metrics)
    Checking hw_common v0.1.0 (/komodo-defi-framework/mm2src/hw_common)
    Checking rpc_task v0.1.0 (/komodo-defi-framework/mm2src/rpc_task)
    Checking mm2_io v0.1.0 (/komodo-defi-framework/mm2src/mm2_io)
    Checking mm2_rpc v0.1.0 (/komodo-defi-framework/mm2src/mm2_rpc)
    Checking mm2_eth v0.1.0 (/komodo-defi-framework/mm2src/mm2_eth)
    Checking mm2_core v0.1.0 (/komodo-defi-framework/mm2src/mm2_core)
    Checking mm2_gui_storage v0.1.0 (/komodo-defi-framework/mm2src/mm2_gui_storage)
    Checking crypto v1.0.0 (/komodo-defi-framework/mm2src/crypto)
    Checking utxo_signer v0.1.0 (/komodo-defi-framework/mm2src/coins/utxo_signer)
    Checking mm2_net v0.1.0 (/komodo-defi-framework/mm2src/mm2_net)
    Checking mm2_git v0.1.0 (/komodo-defi-framework/mm2src/mm2_git)
    Checking mm2_test_helpers v0.1.0 (/komodo-defi-framework/mm2src/mm2_test_helpers)
    Checking coins_activation v0.1.0 (/komodo-defi-framework/mm2src/coins_activation)
    Finished dev [unoptimized + debuginfo] target(s) in 1m 01s
warning: the following packages contain code that will be rejected by a future version of Rust: fs_extra v1.2.0, nom v6.1.2
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 3`

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, what kind of Clippy response is that? I can't seem to reproduce it. Could you provide some guidance on how to achieve that?

@mj-blockydevs I was using cargo clippy --all-features -- -D warnings command.
It's not the first time that cargo clippy --all-features -- -D warnings shows a warning that wasn't caught by cargo clippy --all-targets --all-features -- -D warnings.

hmm, clippy also doesn't detect unused function for me now.

~/RustroverProjects/komodo-defi-framework git:[solana-docker-tests-improvements-local-review]
cargo clippy --all-features -- -D warnings
warning: /Users/sharon/RustroverProjects/komodo-defi-framework/mm2src/mm2_bin_lib/Cargo.toml: file `/Users/sharon/RustroverProjects/komodo-defi-framework/mm2src/mm2_bin_lib/src/mm2_bin.rs` found to be present in multiple build targets:
  * `bin` target `mm2`
  * `bin` target `kdf`
   Compiling mm2_bin_lib v2.1.0-beta (/Users/sharon/RustroverProjects/komodo-defi-framework/mm2src/mm2_bin_lib)
    Finished dev [unoptimized + debuginfo] target(s) in 2.03s
warning: the following packages contain code that will be rejected by a future version of Rust: fs_extra v1.2.0, nom v6.1.2
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 622`

Well, you can search the project to see that it's not used
Screenshot 2024-08-09 at 22 52 33

Sometimes it happens with clippy so I re check usage manually by searching in project files and checking usage in ide
Screenshot 2024-08-09 at 22 58 51

I recommend to add dead code annotation

Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next review iteration! I stopped review midway as some tests are removed and some are not copied right, will continue once this is done in a right way!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this user is not needed anymore

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this user

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this file also

@@ -75,18 +78,20 @@ pub fn docker_tests_runner(tests: &[&TestDescAndFn]) {
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 sol_node = sol_asset_docker_node(&docker, "SOLCLUSTER");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the ticker SOL not SOLCLUSTER

pub fn _solana_supplied_node() -> MarketMakerIt {
let adex_token_address = env::var("ADEX_TOKEN_ADDRESS").expect("ADEX_TOKEN_ADDRESS not set");
println!("adex_token_address: {}", &adex_token_address);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use println!, we use log!

Comment on lines +263 to +273
match error.into_inner() {
WithdrawError::NotSufficientBalance {
coin: _,
available,
required,
} => {
assert_eq!(available, 0.into());
assert_eq!(required, sol_required);
},
e => panic!("Unexpected err {:?}", e),
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change this

   let balance = block_on(sol_coin.my_balance().compat()).unwrap().spendable;	
    let (_, fees) = block_on(sol_coin.estimate_withdraw_fees()).unwrap();	
    let sol_required = lamports_to_sol(fees);	
    assert_eq!(valid_tx_details.my_balance_change, sol_required.clone().neg());	
    assert_eq!(valid_tx_details.total_amount, balance);	
    assert_eq!(valid_tx_details.spent_by_me, balance);	
    assert_eq!(valid_tx_details.received_by_me, &balance - &sol_required);	
    log!("{:?}", valid_tx_details);

From the original test? you just copied and pasted the previous test solana_transaction_simulations_not_enough_for_fees

Comment on lines 313 to 339
let (_, sol_coin) = solana_coin_for_test(PASSPHRASE.to_owned(), SolanaNet::Local);
let valid_tx_details = block_on(
sol_coin
.withdraw(WithdrawRequest::new(
SOL.to_string(),
None,
sol_coin.my_address().unwrap(),
BigDecimal::try_from(0.0001).unwrap(),
false,
None,
None,
))
.compat(),
)
.unwrap();
log!("{:?}", valid_tx_details);

let tx_str = hex::encode(&*valid_tx_details.tx.tx_hex().unwrap().0);
let res = block_on(sol_coin.send_raw_tx(&tx_str).compat()).unwrap();

let res2 = block_on(
sol_coin
.send_raw_tx_bytes(&valid_tx_details.tx.tx_hex().unwrap().0)
.compat(),
)
.unwrap();
assert_eq!(res, res2);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this

    let res = sol_coin	
        .client	
        .get_signatures_for_address(&sol_coin.key_pair.pubkey())	
        .unwrap();	
    let mut history = Vec::new();	
    for cur in res.iter() {	
        let signature = Signature::from_str(cur.signature.clone().as_str()).unwrap();	
        let res = sol_coin	
            .client	
            .get_transaction(&signature, UiTransactionEncoding::JsonParsed)	
            .unwrap();	
        log!("{}", serde_json::to_string(&res).unwrap());	
        let parsed = serde_json::to_value(&res).unwrap();	
        let tx_infos: SolanaConfirmedTransaction = serde_json::from_value(parsed).unwrap();	
        let mut txs = tx_infos.extract_solana_transactions(&sol_coin).unwrap();	
        history.append(&mut txs);	
    }	
    log!("{}", serde_json::to_string(&history).unwrap());

You just copied solana_test_transactions test.

Comment on lines -86 to -136
#[test]
#[cfg(not(target_arch = "wasm32"))]
fn solana_my_balance() {
let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet);
let res = block_on(sol_coin.my_balance().compat()).unwrap();
assert_ne!(res.spendable, BigDecimal::from(0));
}

#[test]
#[cfg(not(target_arch = "wasm32"))]
fn solana_block_height() {
let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet);
let res = block_on(sol_coin.current_block().compat()).unwrap();
log!("block is : {}", res);
assert!(res > 0);
}

#[test]
#[cfg(not(target_arch = "wasm32"))]
fn solana_validate_address() {
let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet);

// invalid len
let res = sol_coin.validate_address("invalidaddressobviously");
assert!(!res.is_valid);
let res = sol_coin.validate_address("GMtMFbuVgjDnzsBd3LLBfM4X8RyYcDGCM92tPq2PG6B2");
assert!(res.is_valid);

// Typo
let res = sol_coin.validate_address("Fr8fraJXAe1cFU81mF7NhHTrUzXjZAJkQE1gUQ11riH");
assert!(!res.is_valid);

// invalid len
let res = sol_coin.validate_address("r8fraJXAe1cFU81mF7NhHTrUzXjZAJkQE1gUQ11riHn");
assert!(!res.is_valid);
}

#[test]
#[cfg(not(target_arch = "wasm32"))]
fn test_sign_message() {
let passphrase = "spice describe gravity federal blast come thank unfair canal monkey style afraid".to_string();
let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet);
let signature = sol_coin.sign_message("test").unwrap();
assert_eq!(
signature,
"4dzKwEteN8nch76zPMEjPX19RsaQwGTxsbtfg2bwGTkGenLfrdm31zvn9GH5rvaJBwivp6ESXx1KYR672ngs3UfF"
);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are just removed and not moved to new files.

@shamardy
Copy link
Collaborator

ref. #1085 (comment) , the solana reference implementation has this latest changes here https://github.com/KomodoPlatform/komodo-defi-framework/commits/solana-ref-impl/

@shamardy shamardy closed this Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants