Skip to content

Commit

Permalink
Use parameters from bootstrap for test
Browse files Browse the repository at this point in the history
  • Loading branch information
soareschen committed Aug 5, 2024
1 parent 2441fee commit 2b40a35
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,18 @@ impl ChainDriverBuilder<StarknetBootstrap> for StarknetBootstrapComponents {
) -> Result<StarknetChainDriver, HermesError> {
let relayer_wallet = wallets
.get("relayer")
.ok_or_else(|| StarknetBootstrap::raise_error("expect relayer wallet to be present"))?;
.ok_or_else(|| StarknetBootstrap::raise_error("expect relayer wallet to be present"))?
.clone();

let user_wallet_a = wallets
.get("user-a")
.ok_or_else(|| StarknetBootstrap::raise_error("expect relayer wallet to be present"))?
.clone();

let user_wallet_b = wallets
.get("user-b")
.ok_or_else(|| StarknetBootstrap::raise_error("expect relayer wallet to be present"))?
.clone();

let json_rpc_url = Url::parse(&format!("http://localhost:{}/", node_config.rpc_port))?;

Expand Down Expand Up @@ -134,6 +145,9 @@ impl ChainDriverBuilder<StarknetBootstrap> for StarknetBootstrapComponents {
node_config,
wallets,
chain_process,
relayer_wallet,
user_wallet_a,
user_wallet_b,
};

Ok(chain_driver)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ pub struct StarknetChainDriver {
pub node_config: StarknetNodeConfig,
pub wallets: BTreeMap<String, StarknetWallet>,
pub chain_process: Child,
pub relayer_wallet: StarknetWallet,
pub user_wallet_a: StarknetWallet,
pub user_wallet_b: StarknetWallet,
}

pub struct StarknetChainDriverComponents;
Expand Down
10 changes: 3 additions & 7 deletions relayer/crates/starknet-integration-tests/tests/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use hermes_starknet_chain_components::traits::queries::token_balance::CanQueryTo
use hermes_starknet_chain_components::types::amount::StarknetAmount;
use hermes_starknet_integration_tests::contexts::bootstrap::StarknetBootstrap;
use hermes_test_components::bootstrap::traits::chain::CanBootstrapChain;
use starknet::macros::felt;

// Note: the test needs to be run with starknet-devnet-rs with the seed 0:
//
Expand All @@ -33,14 +32,11 @@ fn test_starknet_chain_client() {

let chain = &chain_driver.chain;

let account_address =
felt!("0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691");
let account_address = chain_driver.relayer_wallet.account_address;

let token_address =
felt!("0x49D36570D4E46F48E99674BD3FCC84644DDD6B96F7C741B1562B82F9E004DC7");
let token_address = chain_driver.genesis_config.transfer_denom;

let recipient_address =
felt!("0x78662e7352d062084b0010068b99288486c2d8b914f6e2a55ce945f8792c8b1");
let recipient_address = chain_driver.user_wallet_a.account_address;

let sender_balance_a = chain
.query_token_balance(&token_address, &account_address)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,15 @@ where
.map_err(Bootstrap::raise_error)?;

// Use a hard-coded seed 0 for now
let genesis_config = StarknetGenesisConfig { seed: 0 };
let genesis_config = StarknetGenesisConfig {
seed: 0,
transfer_denom: felt!(
"0x49D36570D4E46F48E99674BD3FCC84644DDD6B96F7C741B1562B82F9E004DC7"
),
staking_denom: felt!(
"0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d"
),
};

let node_config = StarknetNodeConfig { rpc_port };

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
use starknet::core::types::Felt;

pub struct StarknetGenesisConfig {
pub seed: u64,
pub transfer_denom: Felt,
pub staking_denom: Felt,
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use starknet::core::types::Felt;

#[derive(Debug, Clone)]
pub struct StarknetWallet {
pub account_address: Felt,
pub signing_key: Felt,
Expand Down

0 comments on commit 2b40a35

Please sign in to comment.