4
4
//! This module contains the transactional test runner instantiation for the Sui adapter
5
5
6
6
use crate :: { args:: * , programmable_transaction_test_parser:: parser:: ParsedCommand } ;
7
+ use crate :: { TransactionalAdapter , ValidatorWithFullnode } ;
7
8
use anyhow:: { anyhow, bail} ;
8
9
use async_trait:: async_trait;
9
10
use bimap:: btree:: BiBTreeMap ;
@@ -38,10 +39,7 @@ use std::{
38
39
path:: Path ,
39
40
sync:: Arc ,
40
41
} ;
41
- use sui_core:: authority:: {
42
- authority_test_utils:: send_and_confirm_transaction_with_execution_error,
43
- test_authority_builder:: TestAuthorityBuilder , AuthorityState ,
44
- } ;
42
+ use sui_core:: authority:: test_authority_builder:: TestAuthorityBuilder ;
45
43
use sui_framework:: BuiltInFramework ;
46
44
use sui_framework:: DEFAULT_FRAMEWORK_PATH ;
47
45
use sui_json_rpc:: api:: QUERY_MAX_RESULT_LIMIT ;
@@ -52,11 +50,13 @@ use sui_protocol_config::{Chain, ProtocolConfig, ProtocolVersion};
52
50
use sui_storage:: {
53
51
key_value_store:: TransactionKeyValueStore , key_value_store_metrics:: KeyValueStoreMetrics ,
54
52
} ;
53
+ use sui_types:: base_types:: SequenceNumber ;
54
+ use sui_types:: crypto:: get_authority_key_pair;
55
+ use sui_types:: effects:: TransactionEffectsAPI ;
55
56
use sui_types:: transaction:: Command ;
56
57
use sui_types:: transaction:: ProgrammableTransaction ;
57
58
use sui_types:: DEEPBOOK_PACKAGE_ID ;
58
59
use sui_types:: MOVE_STDLIB_PACKAGE_ID ;
59
- use sui_types:: { base_types:: SequenceNumber , effects:: TransactionEffectsAPI } ;
60
60
use sui_types:: {
61
61
base_types:: { ObjectID , ObjectRef , SuiAddress , TransactionDigest , SUI_ADDRESS_LENGTH } ,
62
62
crypto:: { get_key_pair_from_rng, AccountKeyPair } ,
@@ -68,7 +68,6 @@ use sui_types::{
68
68
SUI_FRAMEWORK_ADDRESS , SUI_SYSTEM_STATE_OBJECT_ID ,
69
69
} ;
70
70
use sui_types:: { clock:: Clock , SUI_SYSTEM_ADDRESS } ;
71
- use sui_types:: { crypto:: get_authority_key_pair, storage:: ObjectStore } ;
72
71
use sui_types:: { execution_status:: ExecutionStatus , transaction:: TransactionKind } ;
73
72
use sui_types:: { gas:: GasCostSummary , object:: GAS_VALUE_FOR_TESTING } ;
74
73
use sui_types:: { id:: UID , DEEPBOOK_ADDRESS } ;
@@ -106,9 +105,6 @@ const DEFAULT_GAS_BUDGET: u64 = 5_000_000_000;
106
105
const GAS_FOR_TESTING : u64 = GAS_VALUE_FOR_TESTING ;
107
106
108
107
pub struct SuiTestAdapter < ' a > {
109
- pub ( crate ) validator : Arc < AuthorityState > ,
110
- pub ( crate ) kv_store : Arc < TransactionKeyValueStore > ,
111
- pub ( crate ) fullnode : Arc < AuthorityState > ,
112
108
pub ( crate ) compiled_state : CompiledState < ' a > ,
113
109
/// For upgrades: maps an upgraded package name to the original package name.
114
110
package_upgrade_mapping : BTreeMap < Symbol , Symbol > ,
@@ -119,6 +115,7 @@ pub struct SuiTestAdapter<'a> {
119
115
next_fake : ( u64 , u64 ) ,
120
116
gas_price : u64 ,
121
117
pub ( crate ) staged_modules : BTreeMap < Symbol , StagedPackage > ,
118
+ pub ( crate ) executor : Box < dyn TransactionalAdapter > ,
122
119
}
123
120
124
121
pub ( crate ) struct StagedPackage {
@@ -356,9 +353,11 @@ impl<'a> MoveTestAdapter<'a> for SuiTestAdapter<'a> {
356
353
) ) ;
357
354
358
355
let mut test_adapter = Self {
359
- validator,
360
- kv_store,
361
- fullnode,
356
+ executor : Box :: new ( ValidatorWithFullnode {
357
+ validator,
358
+ fullnode,
359
+ kv_store,
360
+ } ) ,
362
361
compiled_state : CompiledState :: new (
363
362
named_address_mapping,
364
363
pre_compiled_deps,
@@ -1106,13 +1105,8 @@ impl<'a> SuiTestAdapter<'a> {
1106
1105
. intent_message ( )
1107
1106
. value
1108
1107
. contains_shared_object ( ) ;
1109
- let ( txn, effects, error_opt) = send_and_confirm_transaction_with_execution_error (
1110
- & self . validator ,
1111
- Some ( & self . fullnode ) ,
1112
- transaction,
1113
- with_shared,
1114
- )
1115
- . await ?;
1108
+ let ( effects, error_opt) = self . executor . execute_txn ( transaction) . await ?;
1109
+ let digest = effects. transaction_digest ( ) ;
1116
1110
let mut created_ids: Vec < _ > = effects
1117
1111
. created ( )
1118
1112
. iter ( )
@@ -1164,10 +1158,9 @@ impl<'a> SuiTestAdapter<'a> {
1164
1158
match effects. status ( ) {
1165
1159
ExecutionStatus :: Success { .. } => {
1166
1160
let events = self
1167
- . validator
1161
+ . executor
1168
1162
. query_events (
1169
- & self . kv_store ,
1170
- EventFilter :: Transaction ( * txn. digest ( ) ) ,
1163
+ EventFilter :: Transaction ( * digest) ,
1171
1164
None ,
1172
1165
* QUERY_MAX_RESULT_LIMIT ,
1173
1166
/* descending */ false ,
@@ -1211,7 +1204,7 @@ impl<'a> SuiTestAdapter<'a> {
1211
1204
gas_price : Option < u64 > ,
1212
1205
) -> anyhow:: Result < TxnSummary > {
1213
1206
let results = self
1214
- . fullnode
1207
+ . executor
1215
1208
. dev_inspect_transaction_block ( sender, transaction_kind, gas_price)
1216
1209
. await ?;
1217
1210
let DevInspectResults {
@@ -1279,9 +1272,9 @@ impl<'a> SuiTestAdapter<'a> {
1279
1272
1280
1273
fn get_object ( & self , id : & ObjectID , version : Option < SequenceNumber > ) -> anyhow:: Result < Object > {
1281
1274
let obj_res = if let Some ( v) = version {
1282
- self . validator . database . get_object_by_key ( id, v)
1275
+ self . executor . get_object_by_key ( id, v)
1283
1276
} else {
1284
- self . validator . database . get_object ( id)
1277
+ self . executor . get_object ( id)
1285
1278
} ;
1286
1279
match obj_res {
1287
1280
Ok ( Some ( obj) ) => Ok ( obj) ,
0 commit comments