-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check if relayer funds are enough to process submitted transaction (e…
…stimates). (#53) * Check if realyer funds are enough to process submitted transaction (estimates). * Code review changes. * Code review changes.
- Loading branch information
Showing
9 changed files
with
173 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.idea/ | ||
target/ | ||
.env | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
mod common; | ||
|
||
use tx_sitter::client::ClientError; | ||
|
||
use crate::common::prelude::*; | ||
|
||
const ESCALATION_INTERVAL: Duration = Duration::from_secs(2); | ||
const ANVIL_BLOCK_TIME: u64 = 6; | ||
|
||
#[tokio::test] | ||
async fn send_when_insufficient_funds() -> eyre::Result<()> { | ||
setup_tracing(); | ||
|
||
let (db_url, _db_container) = setup_db().await?; | ||
let anvil = AnvilBuilder::default() | ||
.block_time(ANVIL_BLOCK_TIME) | ||
.spawn() | ||
.await?; | ||
|
||
let (_service, client) = ServiceBuilder::default() | ||
.escalation_interval(ESCALATION_INTERVAL) | ||
.build(&anvil, &db_url) | ||
.await?; | ||
|
||
let CreateApiKeyResponse { api_key } = | ||
client.create_relayer_api_key(DEFAULT_RELAYER_ID).await?; | ||
|
||
// Send a transaction | ||
let value: U256 = parse_units("1", "ether")?.into(); | ||
for _ in 0..10 { | ||
let tx = client | ||
.send_tx( | ||
&api_key, | ||
&SendTxRequest { | ||
to: ARBITRARY_ADDRESS.into(), | ||
value: value.into(), | ||
gas_limit: U256::from_dec_str("1000000000000")?.into(), | ||
..Default::default() | ||
}, | ||
) | ||
.await; | ||
|
||
if let Err(ClientError::TxSitter(status_code, message)) = tx { | ||
assert_eq!(status_code, reqwest::StatusCode::UNPROCESSABLE_ENTITY); | ||
assert_eq!( | ||
message, | ||
"Relayer funds are insufficient for transaction to be mined." | ||
); | ||
return Ok(()); | ||
} | ||
} | ||
|
||
eyre::bail!("Should return error response with information about insufficient funds.") | ||
} |