mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-18 12:44:19 +01:00
Fix tests (#82)
This commit is contained in:
committed by
GitHub
parent
cf78fc1ab3
commit
f037622b91
@@ -15,7 +15,7 @@ var inputs = []domain.Vtxo{
|
||||
},
|
||||
Receiver: domain.Receiver{
|
||||
Pubkey: "030000000000000000000000000000000000000000000000000000000000000001",
|
||||
Amount: 500,
|
||||
Amount: 1000,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -59,11 +59,11 @@ func TestPayment(t *testing.T) {
|
||||
err = payment.AddReceivers([]domain.Receiver{
|
||||
{
|
||||
Pubkey: "030000000000000000000000000000000000000000000000000000000000000001",
|
||||
Amount: 200,
|
||||
Amount: 450,
|
||||
},
|
||||
{
|
||||
Pubkey: "020000000000000000000000000000000000000000000000000000000000000002",
|
||||
Amount: 300,
|
||||
Amount: 550,
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -82,7 +82,16 @@ func TestPayment(t *testing.T) {
|
||||
receivers: []domain.Receiver{
|
||||
{
|
||||
Pubkey: "030000000000000000000000000000000000000000000000000000000000000001",
|
||||
Amount: 100,
|
||||
Amount: 400,
|
||||
},
|
||||
},
|
||||
expectedErr: "receiver amount must be greater than dust",
|
||||
},
|
||||
{
|
||||
receivers: []domain.Receiver{
|
||||
{
|
||||
Pubkey: "030000000000000000000000000000000000000000000000000000000000000001",
|
||||
Amount: 600,
|
||||
},
|
||||
},
|
||||
expectedErr: "input and output amounts mismatch",
|
||||
|
||||
@@ -12,19 +12,66 @@ var (
|
||||
dustAmount = uint64(450)
|
||||
payments = []domain.Payment{
|
||||
{
|
||||
Id: "0",
|
||||
Inputs: []domain.Vtxo{{}},
|
||||
Receivers: []domain.Receiver{{}, {}, {}},
|
||||
Id: "0",
|
||||
Inputs: []domain.Vtxo{{
|
||||
VtxoKey: domain.VtxoKey{
|
||||
Txid: txid,
|
||||
VOut: 0,
|
||||
},
|
||||
Receiver: domain.Receiver{
|
||||
Pubkey: pubkey,
|
||||
Amount: 2000,
|
||||
},
|
||||
}},
|
||||
Receivers: []domain.Receiver{
|
||||
{
|
||||
Pubkey: pubkey,
|
||||
Amount: 700,
|
||||
},
|
||||
{
|
||||
Pubkey: pubkey,
|
||||
Amount: 700,
|
||||
},
|
||||
{
|
||||
Pubkey: pubkey,
|
||||
Amount: 600,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Id: "1",
|
||||
Inputs: []domain.Vtxo{{}, {}},
|
||||
Receivers: []domain.Receiver{{}},
|
||||
Id: "1",
|
||||
Inputs: []domain.Vtxo{
|
||||
{
|
||||
VtxoKey: domain.VtxoKey{
|
||||
Txid: txid,
|
||||
VOut: 0,
|
||||
},
|
||||
Receiver: domain.Receiver{
|
||||
Pubkey: pubkey,
|
||||
Amount: 1000,
|
||||
},
|
||||
},
|
||||
{
|
||||
VtxoKey: domain.VtxoKey{
|
||||
Txid: txid,
|
||||
VOut: 0,
|
||||
},
|
||||
Receiver: domain.Receiver{
|
||||
Pubkey: pubkey,
|
||||
Amount: 1000,
|
||||
},
|
||||
},
|
||||
},
|
||||
Receivers: []domain.Receiver{{
|
||||
Pubkey: pubkey,
|
||||
Amount: 2000,
|
||||
}},
|
||||
},
|
||||
}
|
||||
emptyPtx = "cHNldP8BAgQCAAAAAQQBAAEFAQABBgEDAfsEAgAAAAA="
|
||||
emptyTx = "0200000000000000000000"
|
||||
txid = "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
pubkey = "030000000000000000000000000000000000000000000000000000000000000001"
|
||||
congestionTree = domain.CongestionTree{
|
||||
{
|
||||
{
|
||||
|
||||
@@ -52,7 +52,7 @@ func createTestPoolTx(sharedOutputAmount, numberOfInputs uint64) (string, error)
|
||||
return "", err
|
||||
}
|
||||
|
||||
connectorsAmount := numberOfInputs * (450 + 500)
|
||||
connectorsAmount := numberOfInputs*450 + 500
|
||||
|
||||
err = updater.AddOutputs([]psetv2.OutputArgs{
|
||||
{
|
||||
@@ -116,7 +116,7 @@ func (*mockedWalletService) Status(ctx context.Context) (ports.WalletStatus, err
|
||||
|
||||
// Transfer implements ports.WalletService.
|
||||
func (*mockedWalletService) Transfer(ctx context.Context, outs []ports.TxOutput) (string, error) {
|
||||
return createTestPoolTx(outs[0].GetAmount(), (450+500)*1)
|
||||
return createTestPoolTx(outs[0].GetAmount(), 1)
|
||||
}
|
||||
|
||||
func TestBuildCongestionTree(t *testing.T) {
|
||||
@@ -139,7 +139,7 @@ func TestBuildCongestionTree(t *testing.T) {
|
||||
},
|
||||
Receiver: domain.Receiver{
|
||||
Pubkey: "020000000000000000000000000000000000000000000000000000000000000002",
|
||||
Amount: 600,
|
||||
Amount: 1100,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -150,7 +150,7 @@ func TestBuildCongestionTree(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Pubkey: "020000000000000000000000000000000000000000000000000000000000000002",
|
||||
Amount: 400,
|
||||
Amount: 500,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -170,7 +170,7 @@ func TestBuildCongestionTree(t *testing.T) {
|
||||
},
|
||||
Receiver: domain.Receiver{
|
||||
Pubkey: "020000000000000000000000000000000000000000000000000000000000000002",
|
||||
Amount: 600,
|
||||
Amount: 1100,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -181,7 +181,7 @@ func TestBuildCongestionTree(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Pubkey: "020000000000000000000000000000000000000000000000000000000000000002",
|
||||
Amount: 400,
|
||||
Amount: 500,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -195,7 +195,7 @@ func TestBuildCongestionTree(t *testing.T) {
|
||||
},
|
||||
Receiver: domain.Receiver{
|
||||
Pubkey: "020000000000000000000000000000000000000000000000000000000000000002",
|
||||
Amount: 600,
|
||||
Amount: 1100,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -206,7 +206,7 @@ func TestBuildCongestionTree(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Pubkey: "020000000000000000000000000000000000000000000000000000000000000002",
|
||||
Amount: 400,
|
||||
Amount: 500,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -220,7 +220,7 @@ func TestBuildCongestionTree(t *testing.T) {
|
||||
},
|
||||
Receiver: domain.Receiver{
|
||||
Pubkey: "020000000000000000000000000000000000000000000000000000000000000002",
|
||||
Amount: 600,
|
||||
Amount: 1100,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -231,13 +231,13 @@ func TestBuildCongestionTree(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Pubkey: "020000000000000000000000000000000000000000000000000000000000000002",
|
||||
Amount: 400,
|
||||
Amount: 500,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedNodesNum: 5,
|
||||
expectedLeavesNum: 2,
|
||||
expectedLeavesNum: 3,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -300,16 +300,14 @@ func TestBuildCongestionTree(t *testing.T) {
|
||||
func TestBuildForfeitTxs(t *testing.T) {
|
||||
builder := txbuilder.NewTxBuilder(network.Liquid)
|
||||
|
||||
poolTx, err := createTestPoolTx(1000, 450*2)
|
||||
// TODO
|
||||
poolTx, err := createTestPoolTx(1000, 2)
|
||||
require.NoError(t, err)
|
||||
|
||||
poolPset, err := psetv2.NewPsetFromBase64(poolTx)
|
||||
tx, err := transaction.NewTxFromHex(poolTx)
|
||||
require.NoError(t, err)
|
||||
|
||||
poolTxUnsigned, err := poolPset.UnsignedTx()
|
||||
require.NoError(t, err)
|
||||
|
||||
poolTxID := poolTxUnsigned.TxHash().String()
|
||||
poolTxID := tx.TxHash().String()
|
||||
|
||||
fixtures := []struct {
|
||||
payments []domain.Payment
|
||||
@@ -338,7 +336,7 @@ func TestBuildForfeitTxs(t *testing.T) {
|
||||
},
|
||||
Receiver: domain.Receiver{
|
||||
Pubkey: "020000000000000000000000000000000000000000000000000000000000000002",
|
||||
Amount: 400,
|
||||
Amount: 500,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -349,7 +347,7 @@ func TestBuildForfeitTxs(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Pubkey: "020000000000000000000000000000000000000000000000000000000000000002",
|
||||
Amount: 400,
|
||||
Amount: 500,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user