Test invalid amounts
MODIFY
MagicalCryptoWallet.Tests/RegTests.cs
MagicalCryptoWallet.Tests/RegTests.cs
@@ -1044,13 +1044,23 @@ namespace MagicalCryptoWallet.Tests
// toSend amount sum has to be in range 0 to 2099999997690000
await Assert.ThrowsAsync<ArgumentOutOfRangeException>( async ()=> await wallet.BuildTransactionAsync(null, invalidOperationList, 2) );
+ // toSend negative sum amount
+ var operations = new[]{
+ new WalletService.Operation(scp, -10000) };
+ await Assert.ThrowsAsync<ArgumentException>( async ()=> await wallet.BuildTransactionAsync(null, operations, 2) );
+
+ // toSend negative operation amount
+ operations = new[]{
+ new WalletService.Operation(scp, 20000),
+ new WalletService.Operation(scp, -10000) };
+ await Assert.ThrowsAsync<ArgumentException>( async ()=> await wallet.BuildTransactionAsync(null, operations, 2) );
+
// toSend ammount sum has to be less than ulong.MaxValue
await Assert.ThrowsAsync<OverflowException>( async ()=> await wallet.BuildTransactionAsync(null, overflowOperationList, 2) );
// allowedInputs cannot be empty
await Assert.ThrowsAsync<ArgumentException>( async ()=> await wallet.BuildTransactionAsync(null, validOperationList, 2, false, null, null, new TxoRef[0]) );
-
// Get some money, make it confirm.
var key = wallet.GetReceiveKey("foo label");
var txid = await Global.RpcClient.SendToAddressAsync(key.GetP2wpkhAddress(network), new Money(1m, MoneyUnit.BTC));

Test invalid amounts