2828using NBitcoin ;
2929using NBitcoin . Protocol ;
3030using Newtonsoft . Json ;
31+ using NLog . Time ;
3132using Xunit ;
3233
3334namespace Blockcore . Features . Wallet . Tests
@@ -3020,11 +3021,12 @@ public void RemoveTransactionsByIdsWhenTransactionsAreUnconfirmedReturnsRemovedT
30203021 // Add two unconfirmed transactions.
30213022 uint256 trxId = uint256 . Parse ( "d6043add63ec364fcb591cf209285d8e60f1cc06186d4dcbce496cdbb4303400" ) ;
30223023 int counter = 0 ;
3024+ DateTimeOffset creationTime = default ;
30233025
3024- var trxUnconfirmed1 = new TransactionOutputData { OutPoint = new OutPoint ( new uint256 ( 1 ) , 1 ) , Amount = 10 , Id = trxId >> counter ++ , Address = firstAccount . ExternalAddresses . ElementAt ( 0 ) . Address } ;
3025- var trxUnconfirmed2 = new TransactionOutputData { OutPoint = new OutPoint ( new uint256 ( 1 ) , 2 ) , Amount = 10 , Id = trxId >> counter ++ , Address = firstAccount . InternalAddresses . ElementAt ( 0 ) . Address } ;
3026- var trxConfirmed1 = new TransactionOutputData { OutPoint = new OutPoint ( new uint256 ( 1 ) , 3 ) , Amount = 10 , Id = trxId >> counter ++ , BlockHeight = 50000 , Address = firstAccount . ExternalAddresses . ElementAt ( 1 ) . Address } ;
3027- var trxConfirmed2 = new TransactionOutputData { OutPoint = new OutPoint ( new uint256 ( 1 ) , 4 ) , Amount = 10 , Id = trxId >> counter ++ , BlockHeight = 50001 , Address = firstAccount . InternalAddresses . ElementAt ( 1 ) . Address } ;
3026+ var trxUnconfirmed1 = new TransactionOutputData { OutPoint = new OutPoint ( new uint256 ( 1 ) , 1 ) , Amount = 10 , Id = trxId >> counter ++ , Address = firstAccount . ExternalAddresses . ElementAt ( 0 ) . Address , CreationTime = creationTime } ;
3027+ var trxUnconfirmed2 = new TransactionOutputData { OutPoint = new OutPoint ( new uint256 ( 1 ) , 2 ) , Amount = 10 , Id = trxId >> counter ++ , Address = firstAccount . InternalAddresses . ElementAt ( 0 ) . Address , CreationTime = creationTime } ;
3028+ var trxConfirmed1 = new TransactionOutputData { OutPoint = new OutPoint ( new uint256 ( 1 ) , 3 ) , Amount = 10 , Id = trxId >> counter ++ , BlockHeight = 50000 , Address = firstAccount . ExternalAddresses . ElementAt ( 1 ) . Address , CreationTime = creationTime } ;
3029+ var trxConfirmed2 = new TransactionOutputData { OutPoint = new OutPoint ( new uint256 ( 1 ) , 4 ) , Amount = 10 , Id = trxId >> counter ++ , BlockHeight = 50001 , Address = firstAccount . InternalAddresses . ElementAt ( 1 ) . Address , CreationTime = creationTime } ;
30283030
30293031 wallet . walletStore . InsertOrUpdate ( trxUnconfirmed1 ) ;
30303032 wallet . walletStore . InsertOrUpdate ( trxConfirmed1 ) ;
@@ -3041,8 +3043,8 @@ public void RemoveTransactionsByIdsWhenTransactionsAreUnconfirmedReturnsRemovedT
30413043 List < TransactionOutputData > remainingTrxs = firstAccount . GetCombinedAddresses ( ) . SelectMany ( a => wallet . walletStore . GetForAddress ( a . Address ) ) . ToList ( ) ;
30423044 Assert . Equal ( 2 , remainingTrxs . Count ( ) ) ;
30433045 Assert . Equal ( 2 , result . Count ) ;
3044- Assert . Contains ( ( trxUnconfirmed1 . Id , trxConfirmed1 . CreationTime ) , result ) ;
3045- Assert . Contains ( ( trxUnconfirmed2 . Id , trxConfirmed2 . CreationTime ) , result ) ;
3046+ Assert . Contains ( result , i => i . Item1 == trxUnconfirmed1 . Id ) ;
3047+ Assert . Contains ( result , i => i . Item1 == trxUnconfirmed2 . Id ) ;
30463048 Assert . DoesNotContain ( trxUnconfirmed1 , remainingTrxs ) ;
30473049 Assert . DoesNotContain ( trxUnconfirmed2 , remainingTrxs ) ;
30483050 }
@@ -3164,17 +3166,19 @@ public void RemoveTransactionsByIdsAlsoRemovesUnconfirmedSpendingDetailsTransact
31643166 uint256 trxId = uint256 . Parse ( "d6043add63ec364fcb591cf209285d8e60f1cc06186d4dcbce496cdbb4303400" ) ;
31653167 int counter = 0 ;
31663168
3169+ DateTimeOffset creationTime = default ;
3170+
31673171 // Confirmed transaction with confirmed spending.
3168- var confirmedSpendingDetails = new SpendingDetails { TransactionId = trxId >> counter ++ , BlockHeight = 500002 } ;
3169- var trxConfirmed1 = new TransactionOutputData { OutPoint = new OutPoint ( new uint256 ( 1 ) , 3 ) , Amount = 10 , Id = trxId >> counter ++ , BlockHeight = 50000 , SpendingDetails = confirmedSpendingDetails , Address = firstAccount . ExternalAddresses . ElementAt ( 1 ) . Address } ;
3172+ var confirmedSpendingDetails = new SpendingDetails { TransactionId = trxId >> counter ++ , BlockHeight = 500002 , CreationTime = creationTime } ;
3173+ var trxConfirmed1 = new TransactionOutputData { OutPoint = new OutPoint ( new uint256 ( 1 ) , 3 ) , Amount = 10 , Id = trxId >> counter ++ , BlockHeight = 50000 , SpendingDetails = confirmedSpendingDetails , Address = firstAccount . ExternalAddresses . ElementAt ( 1 ) . Address , CreationTime = creationTime } ;
31703174
31713175 // Confirmed transaction with unconfirmed spending.
31723176 uint256 unconfirmedTransactionId = trxId >> counter ++ ;
3173- var unconfirmedSpendingDetails1 = new SpendingDetails { TransactionId = unconfirmedTransactionId } ;
3174- var trxConfirmed2 = new TransactionOutputData { OutPoint = new OutPoint ( new uint256 ( 1 ) , 1 ) , Amount = 10 , Id = trxId >> counter ++ , BlockHeight = 50001 , SpendingDetails = unconfirmedSpendingDetails1 , Address = firstAccount . InternalAddresses . ElementAt ( 1 ) . Address } ;
3177+ var unconfirmedSpendingDetails1 = new SpendingDetails { TransactionId = unconfirmedTransactionId , CreationTime = creationTime } ;
3178+ var trxConfirmed2 = new TransactionOutputData { OutPoint = new OutPoint ( new uint256 ( 1 ) , 1 ) , Amount = 10 , Id = trxId >> counter ++ , BlockHeight = 50001 , SpendingDetails = unconfirmedSpendingDetails1 , Address = firstAccount . InternalAddresses . ElementAt ( 1 ) . Address , CreationTime = creationTime } ;
31753179
31763180 // Unconfirmed transaction.
3177- var trxUnconfirmed1 = new TransactionOutputData { OutPoint = new OutPoint ( new uint256 ( 1 ) , 2 ) , Amount = 10 , Id = unconfirmedTransactionId , Address = firstAccount . ExternalAddresses . ElementAt ( 0 ) . Address } ;
3181+ var trxUnconfirmed1 = new TransactionOutputData { OutPoint = new OutPoint ( new uint256 ( 1 ) , 2 ) , Amount = 10 , Id = unconfirmedTransactionId , Address = firstAccount . ExternalAddresses . ElementAt ( 0 ) . Address , CreationTime = creationTime } ;
31783182
31793183 wallet . walletStore . InsertOrUpdate ( trxUnconfirmed1 ) ;
31803184 wallet . walletStore . InsertOrUpdate ( trxConfirmed1 ) ;
@@ -3196,7 +3200,7 @@ public void RemoveTransactionsByIdsAlsoRemovesUnconfirmedSpendingDetailsTransact
31963200 List < TransactionOutputData > remainingTrxs = firstAccount . GetCombinedAddresses ( ) . SelectMany ( a => wallet . walletStore . GetForAddress ( a . Address ) ) . ToList ( ) ;
31973201 Assert . Equal ( 2 , remainingTrxs . Count ) ;
31983202 Assert . Single ( result ) ;
3199- Assert . Contains ( ( unconfirmedTransactionId , trxUnconfirmed1 . CreationTime ) , result ) ;
3203+ Assert . Contains ( result , i => i . Item1 == unconfirmedTransactionId ) ;
32003204 Assert . DoesNotContain ( trxUnconfirmed1 , remainingTrxs ) ;
32013205 Assert . Null ( remainingTrxs . Single ( s => s . OutPoint == trxConfirmed2 . OutPoint ) . SpendingDetails ) ;
32023206 }
0 commit comments