Skip to content

Commit

Permalink
multi: Add tests for CT discount with latest lwk
Browse files Browse the repository at this point in the history
Update the supported CLI version to 0.8.0.

This change ensures that lwkwallet is compatible with
the latest version of the command-line interface.

Adds tests to ensure that the CT discount
mechanism functions correctly with the latest version
of lwk.
  • Loading branch information
YusukeShimizu committed Oct 22, 2024
1 parent 42a38a1 commit 4739346
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
# blockstream-electrs: init at 0.4.1 #299761
# https://github.com/NixOS/nixpkgs/pull/299761/commits/680d27ad847801af781e0a99e4b87ed73965c69a
nixpkgs2.url = "github:NixOS/nixpkgs/680d27ad847801af781e0a99e4b87ed73965c69a";
# lwk: init at wasm_0.6.3 #14bac28
# https://github.com/Blockstream/lwk/releases/tag/wasm_0.6.3
# lwk: init at 9ddd20a806625bb40cd063ad61d80d106809a9fd
# https://github.com/Blockstream/lwk/commit/9ddd20a806625bb40cd063ad61d80d106809a9fd
lwk-flake = {
url = "github:blockstream/lwk/14bac284fe712dd6fdbbbe82bda179a2a236b2fa";
url = "github:blockstream/lwk/9ddd20a806625bb40cd063ad61d80d106809a9fd";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
Expand Down
5 changes: 3 additions & 2 deletions lwk/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ type unvalidatedAddressee struct {
type sendRequest struct {
Addressees []*unvalidatedAddressee `json:"addressees"`
// Optional fee rate in sat/vb
FeeRate *float64 `json:"fee_rate,omitempty"`
WalletName string `json:"name"`
FeeRate *float64 `json:"fee_rate,omitempty"`
WalletName string `json:"name"`
EnableCtDiscount bool `json:"enable_ct_discount"`
}

type sendResponse struct {
Expand Down
8 changes: 5 additions & 3 deletions lwk/lwkwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
// Set up here because ctx is not inherited throughout the current codebase.
defaultContextTimeout = time.Second * 5
minimumFee SatPerVByte = 0.1
supportedCLIVersion = "0.5.1"
supportedCLIVersion = "0.8.0"
)

func SatPerVByteFromFeeBTCPerKb(feeBTCPerKb float64) SatPerVByte {
Expand Down Expand Up @@ -169,8 +169,9 @@ func (r *LWKRpcWallet) CreateAndBroadcastTransaction(swapParams *swap.OpeningPar
Satoshi: swapParams.Amount,
},
},
WalletName: r.c.GetWalletName(),
FeeRate: &feerate,
WalletName: r.c.GetWalletName(),
FeeRate: &feerate,
EnableCtDiscount: true,
})
if err != nil {
return "", "", 0, err
Expand Down Expand Up @@ -233,6 +234,7 @@ func (r *LWKRpcWallet) SendToAddress(address string, amount Satoshi) (string, er
Satoshi: amount,
},
},
EnableCtDiscount: true,
})
if err != nil {
return "", err
Expand Down
2 changes: 1 addition & 1 deletion test/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/stretchr/testify/require"
)

const defaultLines = 30
const defaultLines = 1000

func IsIntegrationTest(t *testing.T) {
if os.Getenv("RUN_INTEGRATION_TESTS") != "1" {
Expand Down
5 changes: 5 additions & 0 deletions testframework/elements.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ func getLiquiddConfig() map[string]string {
"initialfreecoins": "2100000000000000",
"validatepegin": "0",
"chain": "liquidregtest",
"acceptdiscountct": "1",
"creatediscountct": "1",
"minrelaytxfee": "0.00000001",
"mintxfee": "0.00000001",
"blockmintxfee": "0.00000001",
}
}

Expand Down

0 comments on commit 4739346

Please sign in to comment.