@@ -3899,6 +3899,13 @@ fn wallet_abandone_transactions(#[case] seed: Seed) {
3899
3899
wallet. scan_mempool ( txs_to_keep. as_slice ( ) , & WalletEventsNoOp ) . unwrap ( ) ;
3900
3900
let coin_balance = get_coin_balance_with_inactive ( & wallet) ;
3901
3901
assert_eq ! ( coin_balance, coins_after_abandon) ;
3902
+
3903
+ // Abandone the same tx again
3904
+ let result = wallet. abandon_transaction ( DEFAULT_ACCOUNT_INDEX , transaction_id) ;
3905
+ assert_eq ! (
3906
+ result. unwrap_err( ) ,
3907
+ WalletError :: CannotChangeTransactionState ( TxState :: Abandoned , TxState :: Abandoned )
3908
+ ) ;
3902
3909
}
3903
3910
3904
3911
#[ rstest]
@@ -5940,12 +5947,12 @@ fn create_order_fill_partially_conclude(#[case] seed: Seed) {
5940
5947
}
5941
5948
}
5942
5949
5943
- // Create 2 wallet from the same mnemonic.
5950
+ // Create 2 wallets from the same mnemonic.
5944
5951
// Create a pool and a delegation with some stake for both wallets.
5945
- // Add 2 consequtive txs that spend share from delelgation to the first wallet as unconfirmed.
5952
+ // Add 2 consecutive txs that spend share from delegation to the first wallet as unconfirmed.
5946
5953
// Add 1 txs that spends share from delegation with different amount (so that tx id is different)
5947
5954
// via the second wallet and submit it to the block.
5948
- // Check that 2 unconfirmed txs from the first wallet conflicts with confirmed tx and got removed.
5955
+ // Check that 2 unconfirmed txs from the first wallet conflict with confirmed tx and got removed.
5949
5956
#[ rstest]
5950
5957
#[ trace]
5951
5958
#[ case( Seed :: from_entropy( ) ) ]
@@ -6071,6 +6078,7 @@ fn conflicting_delegation_account_nonce(#[case] seed: Seed) {
6071
6078
FeeRate :: from_amount_per_kb ( Amount :: ZERO ) ,
6072
6079
)
6073
6080
. unwrap ( ) ;
6081
+ let spend_from_delegation_tx_1_id = spend_from_delegation_tx_1. transaction ( ) . get_id ( ) ;
6074
6082
6075
6083
wallet
6076
6084
. add_account_unconfirmed_tx (
@@ -6091,6 +6099,7 @@ fn conflicting_delegation_account_nonce(#[case] seed: Seed) {
6091
6099
FeeRate :: from_amount_per_kb ( Amount :: ZERO ) ,
6092
6100
)
6093
6101
. unwrap ( ) ;
6102
+ let spend_from_delegation_tx_2_id = spend_from_delegation_tx_2. transaction ( ) . get_id ( ) ;
6094
6103
6095
6104
wallet
6096
6105
. add_account_unconfirmed_tx (
@@ -6119,6 +6128,7 @@ fn conflicting_delegation_account_nonce(#[case] seed: Seed) {
6119
6128
FeeRate :: from_amount_per_kb ( Amount :: ZERO ) ,
6120
6129
)
6121
6130
. unwrap ( ) ;
6131
+ let spend_from_delegation_tx_3_id = spend_from_delegation_tx_3. transaction ( ) . get_id ( ) ;
6122
6132
6123
6133
let ( _, block5) = create_block (
6124
6134
& chain_config,
@@ -6127,6 +6137,7 @@ fn conflicting_delegation_account_nonce(#[case] seed: Seed) {
6127
6137
Amount :: ZERO ,
6128
6138
4 ,
6129
6139
) ;
6140
+ let block5_id = block5. get_id ( ) ;
6130
6141
scan_wallet ( & mut wallet, BlockHeight :: new ( 4 ) , vec ! [ block5] ) ;
6131
6142
6132
6143
// if confirmed tx is added conflicting txs must be removed from the output cache
@@ -6157,13 +6168,62 @@ fn conflicting_delegation_account_nonce(#[case] seed: Seed) {
6157
6168
coin_balance,
6158
6169
( coin_balance_after_delegating + withdraw_amount_3) . unwrap( )
6159
6170
) ;
6171
+
6172
+ assert_eq ! (
6173
+ * wallet
6174
+ . get_transaction( DEFAULT_ACCOUNT_INDEX , spend_from_delegation_tx_1_id)
6175
+ . unwrap( )
6176
+ . state( ) ,
6177
+ TxState :: Conflicted ( block5_id. into( ) )
6178
+ ) ;
6179
+ assert_eq ! (
6180
+ * wallet
6181
+ . get_transaction( DEFAULT_ACCOUNT_INDEX , spend_from_delegation_tx_2_id)
6182
+ . unwrap( )
6183
+ . state( ) ,
6184
+ TxState :: Conflicted ( block5_id. into( ) )
6185
+ ) ;
6186
+ assert_eq ! (
6187
+ * wallet
6188
+ . get_transaction( DEFAULT_ACCOUNT_INDEX , spend_from_delegation_tx_3_id)
6189
+ . unwrap( )
6190
+ . state( ) ,
6191
+ TxState :: Confirmed (
6192
+ BlockHeight :: new( 5 ) ,
6193
+ chain_config. genesis_block( ) . timestamp( ) ,
6194
+ 0
6195
+ )
6196
+ ) ;
6197
+
6198
+ // Abandone conflicting txs
6199
+ wallet
6200
+ . abandon_transaction ( DEFAULT_ACCOUNT_INDEX , spend_from_delegation_tx_1_id)
6201
+ . unwrap ( ) ;
6202
+ assert_eq ! (
6203
+ * wallet
6204
+ . get_transaction( DEFAULT_ACCOUNT_INDEX , spend_from_delegation_tx_1_id)
6205
+ . unwrap( )
6206
+ . state( ) ,
6207
+ TxState :: Abandoned
6208
+ ) ;
6209
+
6210
+ wallet
6211
+ . abandon_transaction ( DEFAULT_ACCOUNT_INDEX , spend_from_delegation_tx_2_id)
6212
+ . unwrap ( ) ;
6213
+ assert_eq ! (
6214
+ * wallet
6215
+ . get_transaction( DEFAULT_ACCOUNT_INDEX , spend_from_delegation_tx_2_id)
6216
+ . unwrap( )
6217
+ . state( ) ,
6218
+ TxState :: Abandoned
6219
+ ) ;
6160
6220
}
6161
6221
6162
6222
// Create a pool and a delegation with some share.
6163
- // Create 2 consequtive txs that spend from delegation account and add them as unconfirmed.
6223
+ // Create 2 consecutive txs that spend from delegation account and add them as unconfirmed.
6164
6224
// Check confirmed/unconfirmed balance and ensure that account nonce is incremented in OutputCache.
6165
6225
// Submit the first tx in a block.
6166
- // Check that Confirmed balance changed but
6226
+ // Check that confirmed balance changed and unconfirmed stayed the same.
6167
6227
#[ rstest]
6168
6228
#[ trace]
6169
6229
#[ case( Seed :: from_entropy( ) ) ]
@@ -6383,6 +6443,11 @@ fn conflicting_delegation_account_nonce_same_tx(#[case] seed: Seed) {
6383
6443
) ;
6384
6444
}
6385
6445
6446
+ // Issue and mint some tokens
6447
+ // Create an order selling tokens for coins
6448
+ // Create 2 fill order txs and add them to a wallet as unconfirmed
6449
+ // Confirm the first tx in a block and check that it is accounted in confirmed balance
6450
+ // and also that unconfirmed balance has second tx.
6386
6451
#[ rstest]
6387
6452
#[ trace]
6388
6453
#[ case( Seed :: from_entropy( ) ) ]
@@ -6496,7 +6561,7 @@ fn conflicting_order_account_nonce(#[case] seed: Seed) {
6496
6561
assert_eq ! ( actual_order_data. last_nonce, None ) ;
6497
6562
assert_eq ! ( & actual_order_data. conclude_key, address2. as_object( ) ) ;
6498
6563
6499
- // Create 2 fill orders txs and put them in unconfirmed
6564
+ // Create 2 fill order txs and put them in unconfirmed
6500
6565
let order_info = RpcOrderInfo {
6501
6566
conclude_key : address2. clone ( ) . into_object ( ) ,
6502
6567
initially_given : RpcOutputValue :: Token {
0 commit comments