Continued work on coverage, only remaining http codes
Moved exception assertions to BuildTransactionValidationsTestAsync
cleaned up some comments and code
MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -1022,17 +1022,10 @@ namespace WalletWasabi.Tests
var toSend = new[]{ new WalletService.Operation(receive, Money.Zero, "fizz")};
// covers:
- // feeTarget < 2
- // disallow unconfirmed
- // allowed inputs
+ // disallow unconfirmed with allowed inputs
+ // feeTarget < 2 // NOTE: need to correct alowing 0 and 1
res = await wallet.BuildTransactionAsync("password", toSend, 0, false, allowedInputs: allowedInputs);
- // covers:
- // customchange
- // feePc > 1
- res2 = await wallet.BuildTransactionAsync("password", new[] { new WalletService.Operation(new Key().ScriptPubKey, new Money(100, MoneyUnit.MilliBTC), "outgoing")}, 1008, customChange: new Key().ScriptPubKey);
-
-
activeOutput = res.InnerWalletOutputs.Single(x => x.ScriptPubKey == receive);
Assert.Single(res.InnerWalletOutputs);
Assert.Empty(res.OuterWalletOutputs);
@@ -1048,7 +1041,6 @@ namespace WalletWasabi.Tests
Assert.True(inputCountBefore >= res.SpentCoins.Count());
Assert.False(res.SpendsUnconfirmed);
- Logger.LogInfo<RegTests>($"SpendsUnconfirmed: {res.SpendsUnconfirmed}");
Assert.Single(res.Transaction.Transaction.Inputs);
Assert.Single(res.Transaction.Transaction.Outputs);
@@ -1059,24 +1051,22 @@ namespace WalletWasabi.Tests
#endregion
- #region exceptions
+ #region custom change
- // ArgumentException
- var toSendWithTwoZeros = new[]{
- new WalletService.Operation(receive, Money.Zero, "fizz"),
- new WalletService.Operation(receive, Money.Zero, "buzz")
- };
+ // covers:
+ // customchange
+ // feePc > 1
+ res = await wallet.BuildTransactionAsync("password", new[] { new WalletService.Operation(new Key().ScriptPubKey, new Money(100, MoneyUnit.MilliBTC), "outgoing")}, 1008, customChange: new Key().ScriptPubKey);
- Func<Task> throwsArgException = async () =>
- await wallet.BuildTransactionAsync(
- "password",
- toSendWithTwoZeros,
- 1008,
- false,
- allowedInputs: allowedInputs);
+ Assert.True(res.FeePercentOfSent > 1);
- await Assert.ThrowsAsync<ArgumentException>(throwsArgException);
- Logger.LogInfo<RegTests>("Two Money.Zero elements thrown ArgumentException");
+ Logger.LogInfo<RegTests>($"TxId: {res.Transaction.GetHash()}");
+
+ Logger.LogInfo<RegTests>($"Fee: {res.Fee}");
+ Logger.LogInfo<RegTests>($"FeePercentOfSent: {res.FeePercentOfSent} %");
+ Logger.LogInfo<RegTests>($"SpendsUnconfirmed: {res.SpendsUnconfirmed}");
+ Logger.LogInfo<RegTests>($"Active Output: {activeOutput.Amount.ToString(false, true)} {activeOutput.ScriptPubKey.GetDestinationAddress(network)}");
+ Logger.LogInfo<RegTests>($"TxId: {res.Transaction.GetHash()}");
#endregion
}
@@ -1181,6 +1171,18 @@ namespace WalletWasabi.Tests
// allowedInputs cannot be empty
await Assert.ThrowsAsync<ArgumentException>(async () => await wallet.BuildTransactionAsync(null, validOperationList, 2, false, null, null, new TxoRef[0]));
+ // "Only one element can contain Money.Zero
+ var toSendWithTwoZeros = new[]{
+ new WalletService.Operation(scp, Money.Zero, "zero"),
+ new WalletService.Operation(scp, Money.Zero, "zero")};
+ await Assert.ThrowsAsync<ArgumentException>(async () => await wallet.BuildTransactionAsync("password", toSendWithTwoZeros, 1008, false));
+
+ // cannot specify spend all and custom change
+ var spendAll = new[]{
+ new WalletService.Operation(scp, Money.Zero, "spendAll")
+ };
+ await Assert.ThrowsAsync<ArgumentException>(async () => await wallet.BuildTransactionAsync("password", spendAll, 1008, false, customChange: new Key().ScriptPubKey));
+
// Get some money, make it confirm.
var key = wallet.GetReceiveKey("foo label");
var txid = await rpc.SendToAddressAsync(key.GetP2wpkhAddress(network), new Money(1m, MoneyUnit.BTC));

Continued work on coverage, only remaining http codes

- Moved exception assertions to BuildTransactionValidationsTestAsync
- cleaned up some comments and code