@@ -32,7 +32,7 @@ static CHARLIE_SECRET_KEY: Lazy<Arc<SecretKey>> = Lazy::new(|| {
32
32
static CHARLIE_PUBLIC_KEY : Lazy < PublicKey > =
33
33
Lazy :: new ( || PublicKey :: from ( & * CHARLIE_SECRET_KEY . clone ( ) ) ) ;
34
34
35
- const MIN_GAS_PRICE : u8 = 5 ;
35
+ const MIN_GAS_PRICE : u8 = 1 ;
36
36
const CHAIN_NAME : & str = "single-transaction-test-net" ;
37
37
38
38
async fn transfer_to_account < A : Into < U512 > > (
@@ -1023,8 +1023,6 @@ impl SingleTransactionTestCase {
1023
1023
ConfigsOverride :: default ( )
1024
1024
. with_minimum_era_height ( 5 ) // make the era longer so that the transaction doesn't land in the switch block.
1025
1025
. with_balance_hold_interval ( TimeDiff :: from_seconds ( 5 ) )
1026
- . with_min_gas_price ( MIN_GAS_PRICE )
1027
- . with_max_gas_price ( MIN_GAS_PRICE )
1028
1026
. with_chain_name ( "single-transaction-test-net" . to_string ( ) )
1029
1027
}
1030
1028
@@ -3045,25 +3043,27 @@ async fn insufficient_funds_transfer_from_account() {
3045
3043
3046
3044
let transfer_amount = U512 :: max_value ( ) ;
3047
3045
3048
- let mut txn = Transaction :: from (
3046
+ let txn_v1 =
3049
3047
TransactionV1Builder :: new_transfer ( transfer_amount, None , ALICE_PUBLIC_KEY . clone ( ) , None )
3050
3048
. unwrap ( )
3051
3049
. with_chain_name ( CHAIN_NAME )
3052
3050
. with_initiator_addr ( PublicKey :: from ( & * * BOB_SECRET_KEY ) )
3053
3051
. build ( )
3054
- . unwrap ( ) ,
3055
- ) ;
3052
+ . unwrap ( ) ;
3053
+ let price = txn_v1
3054
+ . payment_amount ( )
3055
+ . expect ( "must have payment amount as txns are using classic" ) ;
3056
+ let mut txn = Transaction :: from ( txn_v1) ;
3056
3057
txn. sign ( & BOB_SECRET_KEY ) ;
3057
3058
3058
3059
let ( _txn_hash, _block_height, exec_result) = test. send_transaction ( txn) . await ;
3059
3060
let ExecutionResult :: V2 ( result) = exec_result else {
3060
3061
panic ! ( "Expected ExecutionResult::V2 but got {:?}" , exec_result) ;
3061
3062
} ;
3062
- let transfer_cost: U512 =
3063
- U512 :: from ( test. chainspec ( ) . system_costs_config . mint_costs ( ) . transfer ) * MIN_GAS_PRICE ;
3063
+ let expected_cost: U512 = U512 :: from ( price) * MIN_GAS_PRICE ;
3064
3064
3065
3065
assert_eq ! ( result. error_message. as_deref( ) , Some ( "Insufficient funds" ) ) ;
3066
- assert_eq ! ( result. cost, transfer_cost ) ;
3066
+ assert_eq ! ( result. cost, expected_cost ) ;
3067
3067
}
3068
3068
3069
3069
#[ tokio:: test]
@@ -3089,22 +3089,22 @@ async fn insufficient_funds_add_bid() {
3089
3089
let ( _, bob_initial_balance, _) = test. get_balances ( None ) ;
3090
3090
let bid_amount = bob_initial_balance. total ;
3091
3091
3092
- let mut txn = Transaction :: from (
3092
+ let txn =
3093
3093
TransactionV1Builder :: new_add_bid ( BOB_PUBLIC_KEY . clone ( ) , 0 , bid_amount, None , None , None )
3094
3094
. unwrap ( )
3095
3095
. with_chain_name ( CHAIN_NAME )
3096
3096
. with_initiator_addr ( PublicKey :: from ( & * * BOB_SECRET_KEY ) )
3097
3097
. build ( )
3098
- . unwrap ( ) ,
3099
- ) ;
3098
+ . unwrap ( ) ;
3099
+ let price = txn. payment_amount ( ) . expect ( "must get payment amount" ) ;
3100
+ let mut txn = Transaction :: from ( txn) ;
3100
3101
txn. sign ( & BOB_SECRET_KEY ) ;
3101
3102
3102
3103
let ( _txn_hash, _block_height, exec_result) = test. send_transaction ( txn) . await ;
3103
3104
let ExecutionResult :: V2 ( result) = exec_result else {
3104
3105
panic ! ( "Expected ExecutionResult::V2 but got {:?}" , exec_result) ;
3105
3106
} ;
3106
- let bid_cost: U512 =
3107
- U512 :: from ( test. chainspec ( ) . system_costs_config . auction_costs ( ) . add_bid ) * MIN_GAS_PRICE ;
3107
+ let bid_cost: U512 = U512 :: from ( price) * MIN_GAS_PRICE ;
3108
3108
3109
3109
assert_eq ! (
3110
3110
result. error_message. as_deref( ) ,
@@ -3175,27 +3175,26 @@ async fn insufficient_funds_transfer_from_purse() {
3175
3175
3176
3176
// now we try to transfer from the purse we just created
3177
3177
let transfer_amount = U512 :: max_value ( ) ;
3178
- let mut txn = Transaction :: from (
3179
- TransactionV1Builder :: new_transfer (
3180
- transfer_amount ,
3181
- Some ( uref ) ,
3182
- ALICE_PUBLIC_KEY . clone ( ) ,
3183
- None ,
3184
- )
3185
- . unwrap ( )
3186
- . with_chain_name ( CHAIN_NAME )
3187
- . with_initiator_addr ( PublicKey :: from ( & * * BOB_SECRET_KEY ) )
3188
- . build ( )
3189
- . unwrap ( ) ,
3190
- ) ;
3178
+ let txn = TransactionV1Builder :: new_transfer (
3179
+ transfer_amount ,
3180
+ Some ( uref ) ,
3181
+ ALICE_PUBLIC_KEY . clone ( ) ,
3182
+ None ,
3183
+ )
3184
+ . unwrap ( )
3185
+ . with_chain_name ( CHAIN_NAME )
3186
+ . with_initiator_addr ( PublicKey :: from ( & * * BOB_SECRET_KEY ) )
3187
+ . build ( )
3188
+ . unwrap ( ) ;
3189
+ let price = txn . payment_amount ( ) . expect ( "must get payment amount" ) ;
3190
+ let mut txn = Transaction :: from ( txn ) ;
3191
3191
txn. sign ( & BOB_SECRET_KEY ) ;
3192
3192
3193
3193
let ( _txn_hash, _block_height, exec_result) = test. send_transaction ( txn) . await ;
3194
3194
let ExecutionResult :: V2 ( result) = exec_result else {
3195
3195
panic ! ( "Expected ExecutionResult::V2 but got {:?}" , exec_result) ;
3196
3196
} ;
3197
- let transfer_cost: U512 =
3198
- U512 :: from ( test. chainspec ( ) . system_costs_config . mint_costs ( ) . transfer ) * MIN_GAS_PRICE ;
3197
+ let transfer_cost: U512 = U512 :: from ( price) * MIN_GAS_PRICE ;
3199
3198
3200
3199
assert_eq ! ( result. error_message. as_deref( ) , Some ( "Insufficient funds" ) ) ;
3201
3200
assert_eq ! ( result. cost, transfer_cost) ;
@@ -3223,22 +3222,22 @@ async fn insufficient_funds_when_caller_lacks_minimum_balance() {
3223
3222
3224
3223
let ( _, bob_initial_balance, _) = test. get_balances ( None ) ;
3225
3224
let transfer_amount = bob_initial_balance. total - U512 :: one ( ) ;
3226
- let mut txn = Transaction :: from (
3225
+ let txn =
3227
3226
TransactionV1Builder :: new_transfer ( transfer_amount, None , ALICE_PUBLIC_KEY . clone ( ) , None )
3228
3227
. unwrap ( )
3229
3228
. with_chain_name ( CHAIN_NAME )
3230
3229
. with_initiator_addr ( PublicKey :: from ( & * * BOB_SECRET_KEY ) )
3231
3230
. build ( )
3232
- . unwrap ( ) ,
3233
- ) ;
3231
+ . unwrap ( ) ;
3232
+ let price = txn. payment_amount ( ) . expect ( "must get payment amount" ) ;
3233
+ let mut txn = Transaction :: from ( txn) ;
3234
3234
txn. sign ( & BOB_SECRET_KEY ) ;
3235
3235
3236
3236
let ( _txn_hash, _block_height, exec_result) = test. send_transaction ( txn) . await ;
3237
3237
let ExecutionResult :: V2 ( result) = exec_result else {
3238
3238
panic ! ( "Expected ExecutionResult::V2 but got {:?}" , exec_result) ;
3239
3239
} ;
3240
- let transfer_cost: U512 =
3241
- U512 :: from ( test. chainspec ( ) . system_costs_config . mint_costs ( ) . transfer ) * MIN_GAS_PRICE ;
3240
+ let transfer_cost: U512 = U512 :: from ( price) * MIN_GAS_PRICE ;
3242
3241
3243
3242
assert_eq ! ( result. error_message. as_deref( ) , Some ( "Insufficient funds" ) ) ;
3244
3243
assert_eq ! ( result. cost, transfer_cost) ;
0 commit comments