diff --git a/Cargo.lock b/Cargo.lock index 60f7bb39f..b8b2d6e44 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2106,7 +2106,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" dependencies = [ "atty", - "humantime", + "humantime 1.3.0", "log 0.4.14", "regex", "termcolor", @@ -2119,7 +2119,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" dependencies = [ "atty", - "humantime", + "humantime 1.3.0", + "log 0.4.14", + "regex", + "termcolor", +] + +[[package]] +name = "env_logger" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17392a012ea30ef05a610aa97dfb49496e71c9f676b27879922ea5bdf60d9d3f" +dependencies = [ + "atty", + "humantime 2.1.0", "log 0.4.14", "regex", "termcolor", @@ -3271,6 +3284,12 @@ dependencies = [ "quick-error 1.2.3", ] +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "hyper" version = "0.10.16" @@ -8581,6 +8600,7 @@ dependencies = [ "btc-parachain-service", "btc-relay", "clap 3.0.0-beta.2", + "env_logger 0.8.3", "exchange-rate-oracle", "frame-support", "futures 0.3.15", diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 8b2448b7a..71f2a3120 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -115,3 +115,4 @@ substrate-subxt-client = { git = "https://github.com/interlay/substrate-subxt", btc-parachain = { git = "https://github.com/interlay/btc-parachain", branch = "master", features = ["aura-grandpa"] } btc-parachain-service = { git = "https://github.com/interlay/btc-parachain", branch = "master", features = ["aura-grandpa"] } tempdir = "0.3.7" +env_logger = "0.8.3" \ No newline at end of file diff --git a/runtime/src/rpc.rs b/runtime/src/rpc.rs index ef8a09478..36c5619a5 100644 --- a/runtime/src/rpc.rs +++ b/runtime/src/rpc.rs @@ -271,12 +271,17 @@ impl PolkaBtcProvider { } #[cfg(test)] - async fn get_outdated_nonce_error(&self) -> Error { - let signer = { + pub async fn get_outdated_nonce_error(&self) -> Error { + let signer: PolkaBtcSigner = { let mut signer = self.signer.write().await; - signer.set_nonce(1); + signer.set_nonce(0); + signer.clone() }; - self::set_redeem_period(2).unwrap_err() + self.ext_client + .withdraw_replace_and_watch(&signer, 23) + .await + .unwrap_err() + .into() } } diff --git a/runtime/src/tests.rs b/runtime/src/tests.rs index 5d93a27b5..31b2d7c7b 100644 --- a/runtime/src/tests.rs +++ b/runtime/src/tests.rs @@ -51,11 +51,18 @@ async fn test_getters() { } #[tokio::test] +#[ignore] async fn test_outdated_nonce_matching() { + env_logger::init(); let (client, _tmp_dir) = default_provider_client(AccountKeyring::Alice).await; let provider = setup_provider(client.clone(), AccountKeyring::Alice).await; - set_exchange_rate(client.clone()).await; - assert!(provider.get_outdated_nonce_error().is_outdated_nonce()) + provider + .set_exchange_rate_info(FixedU128::saturating_from_rational(1u128, 100u128)) + .await + .unwrap(); + let err = provider.get_outdated_nonce_error().await; + log::error!("Error: {:?}", err); + assert!(err.is_outdated_nonce()) } #[tokio::test]