Skip to content

Commit

Permalink
Untouch json-json-rpc
Browse files Browse the repository at this point in the history
Signed-off-by: salaheldinsoliman <[email protected]>
  • Loading branch information
salaheldinsoliman committed Sep 26, 2024
1 parent 065513f commit ced0ed6
Show file tree
Hide file tree
Showing 16 changed files with 380 additions and 91 deletions.
2 changes: 1 addition & 1 deletion crates/iota-e2e-tests/tests/checkpoint_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async fn checkpoint_split_brain_test() {
let tx = make_transfer_iota_transaction(&test_cluster.wallet, None, None).await;
test_cluster
.wallet
.execute_transaction_may_fail(tx)
.execute_transaction_may_fail(tx, None)
.await
.ok();

Expand Down
7 changes: 5 additions & 2 deletions crates/iota-e2e-tests/tests/full_node_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,10 @@ async fn test_access_old_object_pruned() {
}

// Check that fullnode would return the same error.
let result = test_cluster.wallet.execute_transaction_may_fail(tx).await;
let result = test_cluster
.wallet
.execute_transaction_may_fail(tx, None)
.await;
assert!(
result.unwrap_err().to_string().contains(
&UserInputError::ObjectVersionUnavailableForConsumption {
Expand Down Expand Up @@ -1405,7 +1408,7 @@ async fn transfer_coin(
.transfer(object_to_send, receiver)
.build(),
);
let resp = context.execute_transaction_must_succeed(txn).await;
let resp = context.execute_transaction_must_succeed(txn, None).await;
Ok((object_to_send.0, sender, receiver, resp.digest, gas_object))
}

Expand Down
74 changes: 40 additions & 34 deletions crates/iota-e2e-tests/tests/multisig_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async fn test_multisig_e2e() {
let tx1 = TestTransactionBuilder::new(multisig_addr, gas, rgp)
.transfer_iota(None, IotaAddress::ZERO)
.build_and_sign_multisig(multisig_pk.clone(), &[&keys[0], &keys[1]], 0b011);
let res = context.execute_transaction_must_succeed(tx1).await;
let res = context.execute_transaction_must_succeed(tx1, None).await;
assert!(res.status_ok().unwrap());

// 2. sign with key 1 and 2 executes successfully.
Expand All @@ -105,7 +105,7 @@ async fn test_multisig_e2e() {
let tx2 = TestTransactionBuilder::new(multisig_addr, gas, rgp)
.transfer_iota(None, IotaAddress::ZERO)
.build_and_sign_multisig(multisig_pk.clone(), &[&keys[1], &keys[2]], 0b110);
let res = context.execute_transaction_must_succeed(tx2).await;
let res = context.execute_transaction_must_succeed(tx2, None).await;
assert!(res.status_ok().unwrap());

// 3. signature 2 and 1 swapped fails to execute.
Expand All @@ -115,7 +115,7 @@ async fn test_multisig_e2e() {
let tx3 = TestTransactionBuilder::new(multisig_addr, gas, rgp)
.transfer_iota(None, IotaAddress::ZERO)
.build_and_sign_multisig(multisig_pk.clone(), &[&keys[2], &keys[1]], 0b110);
let res = context.execute_transaction_may_fail(tx3).await;
let res = context.execute_transaction_may_fail(tx3, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -126,7 +126,7 @@ async fn test_multisig_e2e() {
let tx4 = TestTransactionBuilder::new(multisig_addr, gas, rgp)
.transfer_iota(None, IotaAddress::ZERO)
.build_and_sign_multisig(multisig_pk.clone(), &[&keys[0]], 0b001);
let res = context.execute_transaction_may_fail(tx4).await;
let res = context.execute_transaction_may_fail(tx4, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -137,7 +137,7 @@ async fn test_multisig_e2e() {
let tx5 = TestTransactionBuilder::new(multisig_addr, gas, rgp)
.transfer_iota(None, IotaAddress::ZERO)
.build_and_sign_multisig(multisig_pk.clone(), &[], 0b001);
let res = context.execute_transaction_may_fail(tx5).await;
let res = context.execute_transaction_may_fail(tx5, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -148,7 +148,7 @@ async fn test_multisig_e2e() {
let tx6 = TestTransactionBuilder::new(multisig_addr, gas, rgp)
.transfer_iota(None, IotaAddress::ZERO)
.build_and_sign_multisig(multisig_pk.clone(), &[&keys[0], &keys[0]], 0b011);
let res = context.execute_transaction_may_fail(tx6).await;
let res = context.execute_transaction_may_fail(tx6, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -171,7 +171,7 @@ async fn test_multisig_e2e() {
let tx7 = TestTransactionBuilder::new(wrong_sender, gas, rgp)
.transfer_iota(None, IotaAddress::ZERO)
.build_and_sign_multisig(wrong_multisig_pk.clone(), &[&keys[0], &keys[2]], 0b101);
let res = context.execute_transaction_may_fail(tx7).await;
let res = context.execute_transaction_may_fail(tx7, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand Down Expand Up @@ -232,7 +232,7 @@ async fn test_multisig_with_zklogin_scenerios() {
MultiSig::combine(vec![wrong_sig], multisig_pk.clone()).unwrap(),
);
let tx_1 = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let res = context.execute_transaction_may_fail(tx_1).await;
let res = context.execute_transaction_may_fail(tx_1, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -245,7 +245,7 @@ async fn test_multisig_with_zklogin_scenerios() {
MultiSig::combine(vec![wrong_sig_2], multisig_pk.clone()).unwrap(),
);
let tx_2 = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let res = context.execute_transaction_may_fail(tx_2).await;
let res = context.execute_transaction_may_fail(tx_2, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -258,7 +258,7 @@ async fn test_multisig_with_zklogin_scenerios() {
MultiSig::combine(vec![wrong_sig_3], multisig_pk.clone()).unwrap(),
);
let tx_3 = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let res = context.execute_transaction_may_fail(tx_3).await;
let res = context.execute_transaction_may_fail(tx_3, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -276,7 +276,7 @@ async fn test_multisig_with_zklogin_scenerios() {
MultiSig::combine(vec![wrong_zklogin_sig], multisig_pk.clone()).unwrap(),
);
let tx_4 = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let res = context.execute_transaction_may_fail(tx_4).await;
let res = context.execute_transaction_may_fail(tx_4, None).await;
let pk3 = PublicKey::ZkLogin(
ZkLoginPublicIdentifier::new(zklogin_inputs.get_iss(), zklogin_inputs.get_address_seed())
.unwrap(),
Expand All @@ -299,7 +299,7 @@ async fn test_multisig_with_zklogin_scenerios() {
MultiSig::combine(vec![zklogin_sig_mismatch], multisig_pk.clone()).unwrap(),
);
let tx_5 = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let res = context.execute_transaction_may_fail(tx_5).await;
let res = context.execute_transaction_may_fail(tx_5, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -317,7 +317,7 @@ async fn test_multisig_with_zklogin_scenerios() {
MultiSig::combine(vec![zklogin_sig_wrong_zklogin_inputs], multisig_pk.clone()).unwrap(),
);
let tx_7 = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let res = context.execute_transaction_may_fail(tx_7).await;
let res = context.execute_transaction_may_fail(tx_7, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand Down Expand Up @@ -349,7 +349,7 @@ async fn test_multisig_with_zklogin_scenerios() {
let multisig =
GenericSignature::MultiSig(MultiSig::combine(vec![sig_4], multisig_pk.clone()).unwrap());
let tx_8 = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let res = context.execute_transaction_may_fail(tx_8).await;
let res = context.execute_transaction_may_fail(tx_8, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -366,7 +366,7 @@ async fn test_multisig_with_zklogin_scenerios() {
multisig_pk.clone(),
));
let tx_7 = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let res = context.execute_transaction_may_fail(tx_7).await;
let res = context.execute_transaction_may_fail(tx_7, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -386,7 +386,7 @@ async fn test_multisig_with_zklogin_scenerios() {
let multisig =
GenericSignature::MultiSig(MultiSig::combine(vec![sig_0], multisig_pk.clone()).unwrap());
let tx_8 = Transaction::from_generic_sig_data(tx_data, vec![multisig]);
let _ = context.execute_transaction_must_succeed(tx_8).await;
let _ = context.execute_transaction_must_succeed(tx_8, None).await;

// 2a. good secp256k1 sig used in multisig executes successfully.
let gas = test_cluster
Expand All @@ -400,7 +400,7 @@ async fn test_multisig_with_zklogin_scenerios() {
let multisig =
GenericSignature::MultiSig(MultiSig::combine(vec![sig_1], multisig_pk.clone()).unwrap());
let tx_9 = Transaction::from_generic_sig_data(tx_data, vec![multisig]);
let _ = context.execute_transaction_must_succeed(tx_9).await;
let _ = context.execute_transaction_must_succeed(tx_9, None).await;

// 3a. good secp256r1 sig used in multisig executes successfully.
let gas = test_cluster
Expand All @@ -414,7 +414,7 @@ async fn test_multisig_with_zklogin_scenerios() {
let multisig =
GenericSignature::MultiSig(MultiSig::combine(vec![sig_2], multisig_pk.clone()).unwrap());
let tx_9 = Transaction::from_generic_sig_data(tx_data, vec![multisig]);
let _ = context.execute_transaction_must_succeed(tx_9).await;
let _ = context.execute_transaction_must_succeed(tx_9, None).await;

// 4b. good zklogin sig used in multisig executes successfully.
let gas = test_cluster
Expand All @@ -433,7 +433,7 @@ async fn test_multisig_with_zklogin_scenerios() {
let multisig =
GenericSignature::MultiSig(MultiSig::combine(vec![sig_4], multisig_pk.clone()).unwrap());
let tx_10 = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let _ = context.execute_transaction_must_succeed(tx_10).await;
let _ = context.execute_transaction_must_succeed(tx_10, None).await;

// 4c. good zklogin sig AND good ed25519 combined used in multisig executes
// successfully.
Expand All @@ -455,7 +455,7 @@ async fn test_multisig_with_zklogin_scenerios() {
MultiSig::combine(vec![sig, sig_1], multisig_pk.clone()).unwrap(),
);
let tx_11 = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let _ = context.execute_transaction_must_succeed(tx_11).await;
let _ = context.execute_transaction_must_succeed(tx_11, None).await;

// 9. wrong bitmap fails to execute.
let gas = test_cluster
Expand All @@ -472,7 +472,7 @@ async fn test_multisig_with_zklogin_scenerios() {
multisig_pk.clone(),
));
let tx_11 = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let res = context.execute_transaction_may_fail(tx_11).await;
let res = context.execute_transaction_may_fail(tx_11, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -487,7 +487,7 @@ async fn test_multisig_with_zklogin_scenerios() {
multisig_pk.clone(),
));
let tx_10 = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let res = context.execute_transaction_may_fail(tx_10).await;
let res = context.execute_transaction_may_fail(tx_10, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -514,7 +514,7 @@ async fn test_multisig_with_zklogin_scenerios() {
bad_multisig_pk.clone(),
));
let tx_11 = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let res = context.execute_transaction_may_fail(tx_11).await;
let res = context.execute_transaction_may_fail(tx_11, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -540,7 +540,7 @@ async fn test_multisig_with_zklogin_scenerios() {
bad_multisig_pk,
));
let tx_14 = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let res = context.execute_transaction_may_fail(tx_14).await;
let res = context.execute_transaction_may_fail(tx_14, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -564,7 +564,7 @@ async fn test_multisig_with_zklogin_scenerios() {
small_multisig_pk,
));
let tx_13 = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let res = context.execute_transaction_may_fail(tx_13).await;
let res = context.execute_transaction_may_fail(tx_13, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -589,7 +589,7 @@ async fn test_multisig_with_zklogin_scenerios() {
multisig_pk_with_dup,
));
let tx_14 = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let res = context.execute_transaction_may_fail(tx_14).await;
let res = context.execute_transaction_may_fail(tx_14, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -613,7 +613,7 @@ async fn test_multisig_with_zklogin_scenerios() {
multisig_pk_11,
));
let tx_15 = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let res = context.execute_transaction_may_fail(tx_15).await;
let res = context.execute_transaction_may_fail(tx_15, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -638,7 +638,7 @@ async fn test_multisig_with_zklogin_scenerios() {
multisig_pk_12,
));
let tx_16 = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let res = context.execute_transaction_may_fail(tx_16).await;
let res = context.execute_transaction_may_fail(tx_16, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -662,7 +662,7 @@ async fn test_multisig_with_zklogin_scenerios() {
bad_multisig_empty_pk,
));
let tx_17 = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let res = context.execute_transaction_may_fail(tx_17).await;
let res = context.execute_transaction_may_fail(tx_17, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -682,7 +682,10 @@ async fn test_expired_epoch_zklogin_in_multisig() {
let tx = construct_simple_zklogin_multisig_tx(&test_cluster)
.await
.unwrap();
let res = test_cluster.wallet.execute_transaction_may_fail(tx).await;
let res = test_cluster
.wallet
.execute_transaction_may_fail(tx, None)
.await;
assert!(
res.unwrap_err()
.to_string()
Expand Down Expand Up @@ -725,7 +728,7 @@ async fn test_random_zklogin_in_multisig() {
MultiSig::combine(zklogin_sigs[..9].to_vec(), multisig_pk.clone()).unwrap(),
);
let bad_tx = Transaction::from_generic_sig_data(tx_data.clone(), vec![short_multisig]);
let res = context.execute_transaction_may_fail(bad_tx).await;
let res = context.execute_transaction_may_fail(bad_tx, None).await;
assert!(
res.unwrap_err()
.to_string()
Expand All @@ -736,7 +739,7 @@ async fn test_random_zklogin_in_multisig() {
MultiSig::combine(zklogin_sigs.clone(), multisig_pk.clone()).unwrap(),
);
let tx = Transaction::from_generic_sig_data(tx_data.clone(), vec![multisig]);
let _ = context.execute_transaction_must_succeed(tx).await;
let _ = context.execute_transaction_must_succeed(tx, None).await;
}

#[sim_test]
Expand Down Expand Up @@ -771,7 +774,7 @@ async fn test_multisig_legacy_works() {
.build_and_sign_multisig_legacy(multisig_pk_legacy, &[&keys[0], &keys[1]]);

context
.execute_transaction_must_succeed(transfer_from_multisig)
.execute_transaction_must_succeed(transfer_from_multisig, None)
.await;
}

Expand All @@ -790,7 +793,10 @@ async fn test_zklogin_inside_multisig_feature_deny() {
let tx = construct_simple_zklogin_multisig_tx(&test_cluster)
.await
.unwrap();
let res = test_cluster.wallet.execute_transaction_may_fail(tx).await;
let res = test_cluster
.wallet
.execute_transaction_may_fail(tx, None)
.await;
assert!(
res.unwrap_err()
.to_string()
Expand Down
2 changes: 1 addition & 1 deletion crates/iota-e2e-tests/tests/shared_objects_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ async fn call_shared_object_contract() {
.build();
let effects = test_cluster
.wallet
.execute_transaction_may_fail(test_cluster.wallet.sign_transaction(&transaction))
.execute_transaction_may_fail(test_cluster.wallet.sign_transaction(&transaction), None)
.await
.unwrap()
.effects
Expand Down
6 changes: 3 additions & 3 deletions crates/iota-e2e-tests/tests/zklogin_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ async fn zklogin_end_to_end_test() {
));
let signed_txn = Transaction::from_generic_sig_data(tx_data.clone(), vec![generic_sig]);
let context = &test_cluster.wallet;
let res = context.execute_transaction_may_fail(signed_txn).await;
let res = context.execute_transaction_may_fail(signed_txn, None).await;
assert!(res.is_ok());

// a txn with max_epoch mismatch with proof, fails to execute.
Expand All @@ -136,7 +136,7 @@ async fn zklogin_end_to_end_test() {
Transaction::from_generic_sig_data(tx_data, vec![generic_sig]);
assert!(
context
.execute_transaction_may_fail(signed_txn_with_wrong_max_epoch)
.execute_transaction_may_fail(signed_txn_with_wrong_max_epoch, None)
.await
.is_err()
);
Expand Down Expand Up @@ -184,7 +184,7 @@ async fn test_expired_zklogin_sig() {
let context = &test_cluster.wallet;

let res = context
.execute_transaction_may_fail(signed_txn_expired)
.execute_transaction_may_fail(signed_txn_expired, None)
.await;
assert!(
res.unwrap_err()
Expand Down
Loading

0 comments on commit ced0ed6

Please sign in to comment.