forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Onboard quorum driver to fullnode] 3/n add cluster test case (Mysten…
…Labs#3867) * add execute transaction end points * add execute txn endpoint * add cluster test * rebase * get gas objs * fmt
- Loading branch information
Showing
8 changed files
with
204 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
128 changes: 128 additions & 0 deletions
128
crates/sui-cluster-test/src/test_case/fullnode_execute_transaction_test.rs
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,128 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use crate::{TestCaseImpl, TestContext}; | ||
use async_trait::async_trait; | ||
use sui_json_rpc_types::{SuiExecuteTransactionResponse, SuiExecutionStatus}; | ||
use sui_types::messages::ExecuteTransactionRequestType; | ||
use tracing::info; | ||
|
||
pub struct FullNodeExecuteTransactionTest; | ||
|
||
#[async_trait] | ||
impl TestCaseImpl for FullNodeExecuteTransactionTest { | ||
fn name(&self) -> &'static str { | ||
"FullNodeExecuteTransaction" | ||
} | ||
|
||
fn description(&self) -> &'static str { | ||
"Test executing transaction via Fullnode Quorum Driver" | ||
} | ||
|
||
async fn run(&self, ctx: &mut TestContext) -> Result<(), anyhow::Error> { | ||
ctx.get_sui_from_faucet(Some(3)).await; | ||
let mut txns = ctx.make_transactions(3).await; | ||
assert!( | ||
txns.len() >= 3, | ||
"Expect at least 3 txns, but only got {}. Do we get enough gas objects from faucet?", | ||
txns.len(), | ||
); | ||
|
||
let fullnode = ctx.get_fullnode(); | ||
|
||
// Test WaitForEffectsCert | ||
let txn = txns.swap_remove(0); | ||
let txn_digest = *txn.digest(); | ||
|
||
info!("Test execution with ImmediateReturn"); | ||
let response = fullnode | ||
.execute_transaction_by_fullnode( | ||
txn.clone(), | ||
ExecuteTransactionRequestType::ImmediateReturn, | ||
) | ||
.await?; | ||
if let SuiExecuteTransactionResponse::ImmediateReturn { tx_digest } = response { | ||
assert_eq!(txn_digest, tx_digest); | ||
|
||
// Verify fullnode observes the txn | ||
ctx.let_fullnode_sync().await; | ||
|
||
fullnode | ||
.get_transaction(tx_digest) | ||
.await | ||
.unwrap_or_else(|e| { | ||
panic!( | ||
"Failed get transaction {:?} from fullnode: {:?}", | ||
txn_digest, e | ||
) | ||
}); | ||
} else { | ||
panic!("Expect ImmediateReturn but got {:?}", response); | ||
} | ||
|
||
info!("Test execution with WaitForTxCert"); | ||
let txn = txns.swap_remove(0); | ||
let txn_digest = *txn.digest(); | ||
let response = fullnode | ||
.execute_transaction_by_fullnode( | ||
txn.clone(), | ||
ExecuteTransactionRequestType::WaitForTxCert, | ||
) | ||
.await?; | ||
if let SuiExecuteTransactionResponse::TxCert { certificate } = response { | ||
assert_eq!(txn_digest, certificate.transaction_digest); | ||
|
||
// Verify fullnode observes the txn | ||
ctx.let_fullnode_sync().await; | ||
|
||
fullnode | ||
.get_transaction(txn_digest) | ||
.await | ||
.unwrap_or_else(|e| { | ||
panic!( | ||
"Failed get transaction {:?} from fullnode: {:?}", | ||
txn_digest, e | ||
) | ||
}); | ||
} else { | ||
panic!("Expect TxCert but got {:?}", response); | ||
} | ||
|
||
info!("Test execution with WaitForEffectsCert"); | ||
let txn = txns.swap_remove(0); | ||
let txn_digest = *txn.digest(); | ||
|
||
let response = fullnode | ||
.execute_transaction_by_fullnode(txn, ExecuteTransactionRequestType::WaitForEffectsCert) | ||
.await?; | ||
if let SuiExecuteTransactionResponse::EffectsCert { | ||
certificate, | ||
effects, | ||
} = response | ||
{ | ||
assert_eq!(txn_digest, certificate.transaction_digest); | ||
if !matches!(effects.effects.status, SuiExecutionStatus::Success { .. }) { | ||
panic!( | ||
"Failed to execute transfer tranasction {:?}: {:?}", | ||
txn_digest, effects.effects.status | ||
) | ||
} | ||
// Verify fullnode observes the txn | ||
ctx.let_fullnode_sync().await; | ||
|
||
fullnode | ||
.get_transaction(txn_digest) | ||
.await | ||
.unwrap_or_else(|e| { | ||
panic!( | ||
"Failed get transaction {:?} from fullnode: {:?}", | ||
txn_digest, e | ||
) | ||
}); | ||
} else { | ||
panic!("Expect EffectsCert but got {:?}", response); | ||
} | ||
|
||
Ok(()) | ||
} | ||
} |
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