-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use TransactionFactoryParameters
in tests
#11987
Use TransactionFactoryParameters
in tests
#11987
Conversation
/// <exception cref="ArgumentException"/> | ||
/// <exception cref="ArgumentNullException"/> | ||
/// <exception cref="ArgumentOutOfRangeException"/> | ||
public BuildTransactionResult BuildTransaction( | ||
PaymentIntent payments, | ||
FeeRate feeRate, | ||
IEnumerable<OutPoint>? allowedInputs = null, | ||
IPayjoinClient? payjoinClient = null, | ||
Func<LockTime>? lockTimeSelector = null, | ||
bool allowUnconfirmed = true, | ||
bool allowDoubleSpend = false, | ||
bool tryToSign = true) | ||
{ | ||
TransactionParameters parameters = new(payments, feeRate, allowUnconfirmed, allowDoubleSpend, allowedInputs, tryToSign); | ||
return BuildTransaction(parameters, lockTimeSelector, payjoinClient); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is sort of the main change of this PR.
|
||
namespace WalletWasabi.Tests.Helpers; | ||
|
||
public class TransactionParametersBuilder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might get promoted from the test project to a different project if there is a for it need. I sort of thing there will be, but not just yet.
public static PSBT GenerateRandomTransaction() | ||
{ | ||
var key = new Key(); | ||
var tx = | ||
Network.Main.CreateTransactionBuilder() | ||
.AddCoins(Coin(0.5m, key.PubKey.GetScriptPubKey(ScriptPubKeyType.Segwit))) | ||
.AddKeys(key) | ||
.Send(BitcoinFactory.CreateScript(), Money.Coins(0.5m)) | ||
.BuildPSBT(true); | ||
tx.Finalize(); | ||
return tx; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused method.
@@ -94,7 +82,11 @@ public void LazyPayjoinServerTest() | |||
using Key key = new(); | |||
PaymentIntent payment = new(key.PubKey, amount); | |||
|
|||
var tx = transactionFactory.BuildTransaction(payment, new FeeRate(2m), allowedCoins.Select(x => x.Outpoint), payjoinClient); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fee rate is very often 2, so that was put in the CreateBuilder()
method.
f3d8afb
to
337cdb8
Compare
337cdb8
to
e023942
Compare
|
||
public static SmartCoin[] CreateCoins( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted from the CreateTransactionFactory
method. I believe it will be useful down the line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Code LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM, tests are passing.
I think we can merge this. |
Follow-up to #11738
Easier to review commit by commit.