Skip to content

Commit

Permalink
test: add dup case
Browse files Browse the repository at this point in the history
  • Loading branch information
rkdud007 committed Oct 21, 2024
1 parent cc1b033 commit 28f3c29
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions crates/e2e-tests/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,46 @@ async fn test_wallet_api() -> Result<(), Box<dyn std::error::Error>> {

assert!(receipt.status());

// duplicate the test for backwards compatibility - will remove once we remove the legacy API
let tx_hash: B256 = provider.client().request("wallet_sendTransaction", vec![tx]).await?;
assert!(!provider.get_code_at(signer.address()).await?.is_empty());

Ok(())
}

/// Test the legacy wallet API, will be removed in the future
#[tokio::test]
async fn test_legacy_wallet_api() -> Result<(), Box<dyn std::error::Error>> {
if !ci_info::is_ci() {
return Ok(());
}

let provider = ProviderBuilder::new().on_http(REPLICA_RPC.clone());
let signer = PrivateKeySigner::from_bytes(&b256!(
"59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
))?;

let capabilities: BTreeMap<U256, BTreeMap<String, BTreeMap<String, Vec<Address>>>> =
provider.client().request_noparams("wallet_getCapabilities").await?;

let chain_id = U256::from(provider.get_chain_id().await?);

let delegation_address =
capabilities.get(&chain_id).unwrap().get("delegation").unwrap().get("addresses").unwrap()
[0];

let auth = Authorization {
chain_id: U256::from(provider.get_chain_id().await?),
address: delegation_address,
nonce: provider.get_transaction_count(signer.address()).await?,
};

let signature = signer.sign_hash_sync(&auth.signature_hash())?;
let auth = auth.into_signed(signature);

let tx =
TransactionRequest::default().with_authorization_list(vec![auth]).with_to(signer.address());

let tx_hash: B256 =
provider.client().request("wallet_sendTransaction", vec![tx.clone()]).await?;

let receipt = PendingTransactionBuilder::new(&provider, tx_hash).get_receipt().await?;

Expand Down

0 comments on commit 28f3c29

Please sign in to comment.