@@ -3043,9 +3043,6 @@ fn test_node_contract_on_dedicated_node_shouldnt_be_restored_if_rent_contract_in
3043
3043
3044
3044
let node_id = 1 ;
3045
3045
3046
- // Set the TFT prices
3047
- TFTPriceModule :: set_prices ( RuntimeOrigin :: signed ( alice ( ) ) , 50 , 101 ) . unwrap ( ) ;
3048
-
3049
3046
// Create a rent contract
3050
3047
assert_ok ! ( SmartContractModule :: create_rent_contract(
3051
3048
RuntimeOrigin :: signed( bob( ) ) ,
@@ -3106,7 +3103,8 @@ fn test_node_contract_on_dedicated_node_shouldnt_be_restored_if_rent_contract_in
3106
3103
// Transfer some balance to the owner of the contract to settle only the cost of IP rent (node contract)
3107
3104
// Case 1: See https://github.com/threefoldtech/tfchain/issues/1002
3108
3105
// Calculate the node contract cost
3109
- let ( amount_due, discount_level) = calculate_tft_cost ( node_contract_id, 2 , 10 ) ;
3106
+ let bob_twin_id = 2 ;
3107
+ let ( amount_due, discount_level) = calculate_tft_cost ( node_contract_id, bob_twin_id, 10 ) ;
3110
3108
log:: debug!( "Amount due: {}, discount level: {:?}" , amount_due, discount_level) ;
3111
3109
Balances :: transfer_allow_death ( RuntimeOrigin :: signed ( charlie ( ) ) , bob ( ) , amount_due) . unwrap ( ) ;
3112
3110
@@ -3118,7 +3116,7 @@ fn test_node_contract_on_dedicated_node_shouldnt_be_restored_if_rent_contract_in
3118
3116
// Check if last event is Contract billed event
3119
3117
let events = System :: events ( ) ;
3120
3118
log:: debug!( "Events: {:?}" , events) ;
3121
- let contract_bill_event = types:: ContractBill {
3119
+ let contract_bill = types:: ContractBill {
3122
3120
contract_id : node_contract_id,
3123
3121
timestamp : 1628082132 ,
3124
3122
discount_level,
@@ -3129,7 +3127,7 @@ fn test_node_contract_on_dedicated_node_shouldnt_be_restored_if_rent_contract_in
3129
3127
. last( )
3130
3128
. unwrap( )
3131
3129
. event,
3132
- MockEvent :: SmartContractModule ( SmartContractEvent :: ContractBilled ( contract_bill_event ) )
3130
+ MockEvent :: SmartContractModule ( SmartContractEvent :: ContractBilled ( contract_bill ) )
3133
3131
) ;
3134
3132
3135
3133
// Node contract cost settled (IP address cost), but it should remain in the grace period due to the suspended rent contract
@@ -3149,9 +3147,6 @@ fn test_node_contract_with_overdraft_on_dedicated_node_shouldnt_be_restored_when
3149
3147
3150
3148
let node_id = 1 ;
3151
3149
3152
- // Set the TFT prices
3153
- TFTPriceModule :: set_prices ( RuntimeOrigin :: signed ( alice ( ) ) , 50 , 101 ) . unwrap ( ) ;
3154
-
3155
3150
// Create a rent contract
3156
3151
assert_ok ! ( SmartContractModule :: create_rent_contract(
3157
3152
RuntimeOrigin :: signed( charlie( ) ) ,
@@ -3198,7 +3193,8 @@ fn test_node_contract_with_overdraft_on_dedicated_node_shouldnt_be_restored_when
3198
3193
// Transfer some balance to the owner of the contract to settle only the cost of node resources (rent contract)
3199
3194
// Case 2: see https://github.com/threefoldtech/tfchain/issues/1002
3200
3195
// Calculate the rent contract cost
3201
- let ( contract_cost, discount_level) = calculate_tft_cost ( rent_contract_id, 3 , 20 ) ;
3196
+ let charlie_twin_id = 3 ;
3197
+ let ( contract_cost, discount_level) = calculate_tft_cost ( rent_contract_id, charlie_twin_id, 20 ) ;
3202
3198
let amount_due = contract_cost - spendable_balance;
3203
3199
log:: debug!( "Amount due: {}, discount level: {:?}" , amount_due, discount_level) ;
3204
3200
Balances :: transfer_allow_death ( RuntimeOrigin :: signed ( bob ( ) ) , charlie ( ) , amount_due) . unwrap ( ) ;
@@ -3228,9 +3224,6 @@ fn test_rent_contract_should_wait_for_proper_distribution_of_rewards_when_grace_
3228
3224
3229
3225
let node_id = 1 ;
3230
3226
3231
- // Set the TFT prices
3232
- TFTPriceModule :: set_prices ( RuntimeOrigin :: signed ( alice ( ) ) , 50 , 101 ) . unwrap ( ) ;
3233
-
3234
3227
// Create a rent contract
3235
3228
assert_ok ! ( SmartContractModule :: create_rent_contract(
3236
3229
RuntimeOrigin :: signed( bob( ) ) ,
@@ -3333,13 +3326,14 @@ fn test_rent_contract_should_wait_for_proper_distribution_of_rewards_when_grace_
3333
3326
// Check if the last event is NodeContractCanceled event
3334
3327
assert_eq ! (
3335
3328
events
3336
- . iter( )
3337
- . filter( |e| matches!(
3338
- e. event,
3339
- MockEvent :: SmartContractModule ( SmartContractEvent :: NodeContractCanceled { .. } )
3340
- ) )
3341
- . count( ) ,
3342
- 1
3329
+ . last( )
3330
+ . unwrap( )
3331
+ . event,
3332
+ MockEvent :: SmartContractModule ( SmartContractEvent :: NodeContractCanceled {
3333
+ contract_id: node_contract_id,
3334
+ node_id: node_id,
3335
+ twin_id: 2
3336
+ } )
3343
3337
) ;
3344
3338
// The rent contract should be canceled in the next cycle
3345
3339
let block_number: u64 = 131 ;
@@ -3354,13 +3348,12 @@ fn test_rent_contract_should_wait_for_proper_distribution_of_rewards_when_grace_
3354
3348
let events = System :: events ( ) ;
3355
3349
assert_eq ! (
3356
3350
events
3357
- . iter( )
3358
- . filter( |e| matches!(
3359
- e. event,
3360
- MockEvent :: SmartContractModule ( SmartContractEvent :: RentContractCanceled { .. } )
3361
- ) )
3362
- . count( ) ,
3363
- 1
3351
+ . last( )
3352
+ . unwrap( )
3353
+ . event,
3354
+ MockEvent :: SmartContractModule ( SmartContractEvent :: RentContractCanceled {
3355
+ contract_id: rent_contract_id,
3356
+ } )
3364
3357
) ;
3365
3358
// No part of the user's balance should be reserved
3366
3359
assert_eq ! ( Balances :: reserved_balance( & bob( ) ) , 0 ) ;
@@ -3377,9 +3370,6 @@ fn test_node_contract_in_grace_period_should_maintain_start_block_number_if_rent
3377
3370
3378
3371
let node_id = 1 ;
3379
3372
3380
- // Set the TFT prices
3381
- TFTPriceModule :: set_prices ( RuntimeOrigin :: signed ( alice ( ) ) , 50 , 101 ) . unwrap ( ) ;
3382
-
3383
3373
// Create a rent contract
3384
3374
assert_ok ! ( SmartContractModule :: create_rent_contract(
3385
3375
RuntimeOrigin :: signed( bob( ) ) ,
0 commit comments