Merge pull request #1252 from lightninglabs/chore/remove-custom-channels-tests

itest: remove custom channels tests and backward compat infrastructure
This commit is contained in:
Elle 2026-03-17 09:41:38 +02:00 committed by GitHub
commit 4cedb44ee0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 33 additions and 10097 deletions

View file

@ -304,13 +304,11 @@ jobs:
matrix:
include:
- name: bbolt
args: itest-parallel-no-backward-compat icase=terminal dbbackend=bbolt tranches=4
args: itest-parallel icase=terminal dbbackend=bbolt tranches=4
- name: sqlite
args: itest-parallel-no-backward-compat icase=terminal dbbackend=sqlite tranches=4
args: itest-parallel icase=terminal dbbackend=sqlite tranches=4
- name: postgres
args: itest-parallel-no-backward-compat icase=terminal dbbackend=postgres tranches=4
- name: custom-channels
args: itest-parallel icase=custom_channels tranches=4
args: itest-parallel icase=terminal dbbackend=postgres tranches=4
steps:
- name: git checkout

View file

@ -24,12 +24,6 @@ PUBLIC_URL :=
# versions are checked against this version.
GO_VERSION = 1.25.5
# LITD_COMPAT_VERSIONS is a space-separated list of litd versions that are
# installed before running the integration tests which include backward
# compatibility tests. The list of versions must be in sync with any version
# used in the backwardCompat map in itest/litd_test_list_on_test.go.
LITD_COMPAT_VERSIONS = v0.14.1-alpha v0.15.0-alpha
LOOP_COMMIT := $(shell cat go.mod | \
grep $(LOOP_PKG) | \
head -n1 | \
@ -243,10 +237,6 @@ build-itest-binary:
@$(call print, "Building itest binary.")
CGO_ENABLED=0 $(GOTEST) -v ./itest -tags="$(DEV_TAGS) $(ITEST_TAGS)" -c -o itest/itest.test
install-backward-compat-versions:
@$(call print, "Installing old versions of litd for backward compatibility tests.")
scripts/install-backward-compat-versions.sh '$(LITD_COMPAT_VERSIONS)'
run-itest-only:
@$(call print, "Building itest binary.")
CGO_ENABLED=0 $(GOBUILD) -tags="$(ITEST_TAGS)" -o itest/litd-itest -ldflags "$(ITEST_LDFLAGS)" $(PKG)/cmd/litd
@ -256,22 +246,15 @@ run-itest-only:
rm -rf itest/*.log itest/.logs*; date
scripts/itest_part.sh $(ITEST_FLAGS)
itest-only: build-itest install-backward-compat-versions run-itest-only
itest-only: build-itest run-itest-only
itest: app-build itest-only
itest-no-backward-compat: app-build build-itest run-itest-only
itest-parallel: app-build build-itest install-backward-compat-versions build-itest-binary
itest-parallel: app-build build-itest build-itest-binary
@$(call print, "Running integration tests in parallel.")
rm -rf itest/*.log itest/.logs*; date
scripts/itest_parallel.sh $(ITEST_PARALLELISM) $(NUM_ITEST_TRANCHES) $(SHUFFLE_SEED) $(TEST_FLAGS) $(ITEST_FLAGS)
itest-parallel-no-backward-compat: app-build build-itest build-itest-binary
@$(call print, "Running integration tests in parallel (no backward compat binaries).")
rm -rf itest/*.log itest/.logs*; date
scripts/itest_parallel.sh $(ITEST_PARALLELISM) $(NUM_ITEST_TRANCHES) $(SHUFFLE_SEED) $(TEST_FLAGS) $(ITEST_FLAGS)
# =============
# FLAKE HUNTING
# =============
@ -364,5 +347,5 @@ flakehunter-unit:
go-install go-install-noui go-install-cli app-build release go-release \
docker-release docker-tools scratch check unit unit-cover unit-race \
clean-itest build-itest build-itest-binary itest-only itest \
itest-parallel itest-parallel-no-backward-compat flake-unit fmt lint \
itest-parallel flake-unit fmt lint \
mod mod-check list rpc protos protos-check rpc-js-compile clean

1
go.mod
View file

@ -108,7 +108,6 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-macaroon-bakery/macaroonpb v1.0.0 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/goccy/go-yaml v1.15.23 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect

2
go.sum
View file

@ -846,8 +846,6 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/goccy/go-yaml v1.15.23 h1:WS0GAX1uNPDLUvLkNU2vXq6oTnsmfVFocjQ/4qA48qo=
github.com/goccy/go-yaml v1.15.23/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0=

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -68,26 +68,6 @@ var (
"litdbbackend", terminal.DatabaseBackendBbolt, "Set the "+
"database backend to use when starting a LiT daemon.",
)
// backwardCompatFlagOverride is a map of LiT versions to a map of
// config file flags that need to be overwritten or added for the target
// version to work. If a flag in the map is empty, it means it will be
// removed from the config file of that version.
backwardCompatFlagOverride = map[string]map[string]string{
"v0.14.1-alpha": {
"databasebackend": "",
"lnd.logging.no-commit-hash": "",
},
}
// backwardCompatConfigOverride is a map of LiT versions to a map of
// config file overriding functions.
backwardCompatConfigOverride = map[string]func(*LitNodeConfig){
"v0.14.1-alpha": func(cfg *LitNodeConfig) {
cfg.OldChannelFormat = true
cfg.SkipBalanceChecks = true
},
}
)
// Option is a function for updating a node's configuration.
@ -123,14 +103,6 @@ type LitNodeConfig struct {
LitPort int
LitRESTPort int
// OldChannelFormat is a flag for turning off certain checks for old
// versions of litd during the backward compatibility test.
OldChannelFormat bool
// SkipBalanceChecks is a flag for turning off certain checks for old
// versions of litd during the backward compatibility test.
SkipBalanceChecks bool
// backupDBDir is the path where a database backup is stored, if any.
backupDBDir string
}
@ -648,62 +620,19 @@ func renameFile(fromFileName, toFileName string) {
}
}
// overrideFlagsAndBinary is a helper function that checks if the passed node
// name needs a version downgrade and if so, it will return the new binary
// name and the new arguments.
func (hn *HarnessNode) overrideFlagsAndBinary(backwardCompat map[string]string,
binary string, args []LitArgOption) (string, []LitArgOption) {
noopArg := WithLitArg("taproot-assets.channel.noop-htlcs", "")
if _, ok := backwardCompat[hn.Name()]; !ok {
args = append(args, noopArg)
return binary, args
}
downgradeVersion, ok := backwardCompat[hn.Cfg.Name]
if !ok {
return binary, args
}
newBinary := fmt.Sprintf("%s-%s", binary, downgradeVersion)
flagOverride, ok := backwardCompatFlagOverride[downgradeVersion]
if !ok {
return newBinary, args
}
for k, v := range flagOverride {
if v == "" {
args = append(args, WithoutLitArg(k))
} else {
args = append(args, WithLitArg(k, v))
}
}
cfgOverride, ok := backwardCompatConfigOverride[downgradeVersion]
if ok && cfgOverride != nil {
cfgOverride(hn.Cfg)
}
return newBinary, args
}
// Start launches a new process running lnd. Additionally, the PID of the
// launched process is saved in order to possibly kill the process forcibly
// later.
//
// This may not clean up properly if an error is returned, so the caller should
// call shutdown() regardless of the return value.
func (hn *HarnessNode) Start(litdBinary string,
backwardCompat map[string]string, litdError chan<- error,
func (hn *HarnessNode) Start(litdBinary string, litdError chan<- error,
waitForStart bool, litArgOpts ...LitArgOption) error {
hn.quit = make(chan struct{})
litdBinary, litArgOpts = hn.overrideFlagsAndBinary(
backwardCompat, litdBinary, litArgOpts,
)
noopArg := WithLitArg("taproot-assets.channel.noop-htlcs", "")
litArgOpts = append(litArgOpts, noopArg)
args := hn.Cfg.GenArgs(litArgOpts...)
hn.cmd = exec.Command(litdBinary, args...)

View file

@ -120,8 +120,8 @@ func TestLightningTerminal(t *testing.T) {
lndSubTest := lndHarness.Subtest(t1)
litdHarness, err := NewNetworkHarness(
lndSubTest, chainBackend, binary, feeService,
testCase.backwardCompat,
lndSubTest, chainBackend, binary,
feeService,
)
require.NoError(t1, err)

View file

@ -27,143 +27,4 @@ var allTestCases = []*testCase{
name: "terminal large http header",
test: testLargeHttpHeader,
},
{
name: "custom channels",
test: testCustomChannels,
noAliceBob: true,
},
{
name: "custom channels backward compatibility",
test: testCustomChannels,
noAliceBob: true,
backwardCompat: map[string]string{
"Dave": "v0.14.1-alpha",
"Fabia": "v0.14.1-alpha",
},
},
{
name: "custom channels large",
test: testCustomChannelsLarge,
noAliceBob: true,
},
{
name: "custom channels grouped asset",
test: testCustomChannelsGroupedAsset,
noAliceBob: true,
},
{
name: "custom channels group tranches force close",
test: testCustomChannelsGroupTranchesForceClose,
noAliceBob: true,
},
{
name: "custom channels group tranches htlc force close",
test: testCustomChannelsGroupTranchesHtlcForceClose,
noAliceBob: true,
},
{
name: "custom channels force close",
test: testCustomChannelsForceClose,
noAliceBob: true,
},
{
name: "custom channels breach",
test: testCustomChannelsBreach,
noAliceBob: true,
},
{
name: "custom channels liquidity",
test: testCustomChannelsLiquidityEdgeCases,
noAliceBob: true,
},
{
name: "custom channels liquidity group",
test: testCustomChannelsLiquidityEdgeCasesGroup,
noAliceBob: true,
},
{
name: "custom channels htlc force close",
test: testCustomChannelsHtlcForceClose,
noAliceBob: true,
},
{
name: "custom channels htlc force close MPP",
test: testCustomChannelsHtlcForceCloseMpp,
noAliceBob: true,
},
{
name: "custom channels balance consistency",
test: testCustomChannelsBalanceConsistency,
noAliceBob: true,
},
{
name: "custom channels single asset multi input",
test: testCustomChannelsSingleAssetMultiInput,
noAliceBob: true,
},
{
name: "custom channels passive assets",
test: testCustomChannelsPassiveAssets,
noAliceBob: true,
},
{
name: "custom channels oracle pricing",
test: testCustomChannelsOraclePricing,
noAliceBob: true,
},
{
name: "custom channels fee",
test: testCustomChannelsFee,
noAliceBob: true,
},
{
name: "custom channels forward bandwidth",
test: testCustomChannelsForwardBandwidth,
noAliceBob: true,
},
{
name: "custom channels strict forwarding",
test: testCustomChannelsStrictForwarding,
noAliceBob: true,
},
{
name: "custom channels decode payreq",
test: testCustomChannelsDecodeAssetInvoice,
noAliceBob: true,
},
{
name: "custom channels self-payment",
test: testCustomChannelsSelfPayment,
noAliceBob: true,
},
{
name: "custom channels multi rfq",
test: testCustomChannelsMultiRFQ,
noAliceBob: true,
backwardCompat: map[string]string{
"Yara": "v0.15.0-alpha",
},
},
{
name: "custom channels multi channel pathfinding",
test: testCustomChannelsMultiChannelPathfinding,
noAliceBob: true,
},
{
name: "custom channels self-payment backward " +
"compatibility",
test: testCustomChannelsSelfPayment,
noAliceBob: true,
backwardCompat: map[string]string{
"Alice": "v0.14.1-alpha",
},
},
{
name: "custom channels v1 upgrade",
test: testCustomChannelsV1Upgrade,
noAliceBob: true,
backwardCompat: map[string]string{
"Charlie": "v0.15.0-alpha",
},
},
}

View file

@ -69,11 +69,6 @@ type NetworkHarness struct {
Alice *HarnessNode
Bob *HarnessNode
// backwardCompat is a map of node names to the version of litd that
// should be used for them. If the map is empty, then the latest/current
// version will be used for all nodes.
backwardCompat map[string]string
// Channel for transmitting stderr output from failed lightning node
// to main process.
lndErrorChan chan error
@ -83,20 +78,19 @@ type NetworkHarness struct {
// NewNetworkHarness creates a new network test harness.
func NewNetworkHarness(lndHarness *lntest.HarnessTest, b node.BackendConfig,
litdBinary string, feeService lntest.WebFeeService,
backwardCompat map[string]string) (*NetworkHarness, error) {
litdBinary string,
feeService lntest.WebFeeService) (*NetworkHarness, error) {
n := NetworkHarness{
activeNodes: make(map[int]*HarnessNode),
nodesByPub: make(map[string]*HarnessNode),
lndErrorChan: make(chan error),
netParams: lndHarness.Miner().ActiveNet,
Miner: lndHarness.Miner(),
LNDHarness: lndHarness,
BackendCfg: b,
litdBinary: litdBinary,
feeService: feeService,
backwardCompat: backwardCompat,
activeNodes: make(map[int]*HarnessNode),
nodesByPub: make(map[string]*HarnessNode),
lndErrorChan: make(chan error),
netParams: lndHarness.Miner().ActiveNet,
Miner: lndHarness.Miner(),
LNDHarness: lndHarness,
BackendCfg: b,
litdBinary: litdBinary,
feeService: feeService,
}
return &n, nil
}
@ -377,7 +371,7 @@ func (n *NetworkHarness) newNode(t *testing.T, name string, extraArgs,
n.activeNodes[node.NodeID] = node
n.mtx.Unlock()
err = node.Start(n.litdBinary, n.backwardCompat, n.lndErrorChan, wait)
err = node.Start(n.litdBinary, n.lndErrorChan, wait)
if err != nil {
return nil, err
}
@ -778,72 +772,22 @@ func (n *NetworkHarness) RestartNodeNoUnlock(node *HarnessNode,
}
return node.Start(
n.litdBinary, n.backwardCompat, n.lndErrorChan, wait,
litArgOpts...,
n.litdBinary, n.lndErrorChan, wait, litArgOpts...,
)
}
// suspendCfg contains any configurations related to suspending a node. This may
// change the way the node starts up again.
type suspendCfg struct {
upgrade bool
downgrade string
}
// SuspendOption is a functional option that may change the suspend
// configuration.
type SuspendOption func(cfg *suspendCfg)
// WithUpgrade is a functional option which indicates that the node should be
// upgraded to the latest version of LiT.
func WithUpgrade() SuspendOption {
return func(cfg *suspendCfg) {
cfg.upgrade = true
}
}
// WithDowngrade is a functional option which indicates that the node should be
// downgraded to the defined LiT version.
func WithDowngrade(version string) SuspendOption {
return func(cfg *suspendCfg) {
cfg.downgrade = version
}
}
// SuspendNode stops the given node and returns a callback that can be used to
// start it again. If the upgrade flag is set then any backwards compatibility
// version that the node was running previously will be eliminated, forcing it
// to use the current (latest) build.
func (n *NetworkHarness) SuspendNode(node *HarnessNode,
opts ...SuspendOption) (func() error, error) {
// start it again.
func (n *NetworkHarness) SuspendNode(
node *HarnessNode) (func() error, error) {
if err := node.Stop(); err != nil {
return nil, err
}
cfg := &suspendCfg{}
for _, opt := range opts {
opt(cfg)
}
// If the upgrade flag was set, delete any entry from the backwards
// compatibility map. This will force the node to use the latest build
// of LiT.
if cfg.upgrade {
delete(n.backwardCompat, node.Name())
}
// If a downgrade version was defined, update the backwards
// compatibility entry with that version for this LiT node. This will
// force the node to start up using the defined version.
if cfg.downgrade != "" {
n.backwardCompat[node.Name()] = cfg.downgrade
}
restart := func() error {
return node.Start(
n.litdBinary, n.backwardCompat, n.lndErrorChan, true,
n.litdBinary, n.lndErrorChan, true,
)
}
@ -879,10 +823,8 @@ func (n *NetworkHarness) StopNode(node *HarnessNode) error {
}
// StopAndBackupDB backs up the database of the target node.
func (n *NetworkHarness) StopAndBackupDB(node *HarnessNode,
opts ...SuspendOption) error {
restart, err := n.SuspendNode(node, opts...)
func (n *NetworkHarness) StopAndBackupDB(node *HarnessNode) error {
restart, err := n.SuspendNode(node)
if err != nil {
return err
}
@ -906,10 +848,8 @@ func (n *NetworkHarness) StopAndBackupDB(node *HarnessNode,
// StopAndRestoreDB stops the target node, restores the database from a backup
// and starts the node again.
func (n *NetworkHarness) StopAndRestoreDB(node *HarnessNode,
opts ...SuspendOption) error {
restart, err := n.SuspendNode(node, opts...)
func (n *NetworkHarness) StopAndRestoreDB(node *HarnessNode) error {
restart, err := n.SuspendNode(node)
if err != nil {
return err
}

View file

@ -1,280 +0,0 @@
package itest
import (
"context"
"crypto/tls"
"encoding/hex"
"fmt"
"net"
"testing"
"time"
"github.com/lightninglabs/taproot-assets/asset"
"github.com/lightninglabs/taproot-assets/rfqmath"
"github.com/lightninglabs/taproot-assets/rfqmsg"
"github.com/lightninglabs/taproot-assets/rpcutils"
oraclerpc "github.com/lightninglabs/taproot-assets/taprpc/priceoraclerpc"
"github.com/lightningnetwork/lnd/cert"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)
// oracleHarness is a basic integration test RPC price oracle server harness.
type oracleHarness struct {
oraclerpc.UnimplementedPriceOracleServer
listenAddr string
grpcListener net.Listener
grpcServer *grpc.Server
purchasePrices map[asset.ID]rfqmath.BigIntFixedPoint
salePrices map[asset.ID]rfqmath.BigIntFixedPoint
}
func newOracleHarness(listenAddr string) *oracleHarness {
return &oracleHarness{
listenAddr: listenAddr,
purchasePrices: make(map[asset.ID]rfqmath.BigIntFixedPoint),
salePrices: make(map[asset.ID]rfqmath.BigIntFixedPoint),
}
}
func (o *oracleHarness) setPrice(assetID asset.ID, purchasePrice,
salePrice rfqmath.BigIntFixedPoint) {
o.purchasePrices[assetID] = purchasePrice
o.salePrices[assetID] = salePrice
}
func (o *oracleHarness) start(t *testing.T) {
// Start the mock RPC price oracle service.
//
// Generate self-signed certificate. This allows us to use TLS for the
// gRPC server.
tlsCert, err := generateSelfSignedCert()
require.NoError(t, err)
// Create the gRPC server with TLS
transportCredentials := credentials.NewTLS(&tls.Config{
Certificates: []tls.Certificate{tlsCert},
})
o.grpcServer = grpc.NewServer(grpc.Creds(transportCredentials))
serviceAddr := fmt.Sprintf("rfqrpc://%s", o.listenAddr)
log.Infof("Starting RPC price oracle service at address: %s\n",
serviceAddr)
oraclerpc.RegisterPriceOracleServer(o.grpcServer, o)
go func() {
var err error
o.grpcListener, err = net.Listen("tcp", o.listenAddr)
if err != nil {
log.Errorf("Error oracle listening: %v", err)
return
}
if err := o.grpcServer.Serve(o.grpcListener); err != nil {
log.Errorf("Error oracle serving: %v", err)
}
}()
}
func (o *oracleHarness) stop() {
if o.grpcServer != nil {
o.grpcServer.Stop()
}
if o.grpcListener != nil {
_ = o.grpcListener.Close()
}
}
// getAssetRates returns the asset rates for a given transaction type and
// subject asset max amount.
func (o *oracleHarness) getAssetRates(id asset.ID,
transactionType oraclerpc.TransactionType) (oraclerpc.AssetRates,
error) {
// Determine the rate based on the transaction type.
var subjectAssetRate rfqmath.BigIntFixedPoint
if transactionType == oraclerpc.TransactionType_PURCHASE {
rate, ok := o.purchasePrices[id]
if !ok {
return oraclerpc.AssetRates{}, fmt.Errorf("purchase "+
"price not found for asset ID=%v", id)
}
subjectAssetRate = rate
} else {
rate, ok := o.salePrices[id]
if !ok {
return oraclerpc.AssetRates{}, fmt.Errorf("sale "+
"price not found for asset ID=%v", id)
}
subjectAssetRate = rate
}
// Marshal subject asset rate to RPC format.
rpcSubjectAssetToBtcRate, err := rpcutils.MarshalBigIntFixedPoint(
subjectAssetRate,
)
if err != nil {
return oraclerpc.AssetRates{}, err
}
// Marshal payment asset rate to RPC format.
rpcPaymentAssetToBtcRate, err := rpcutils.MarshalBigIntFixedPoint(
rfqmsg.MilliSatPerBtc,
)
if err != nil {
return oraclerpc.AssetRates{}, err
}
expiry := time.Now().Add(5 * time.Minute).Unix()
return oraclerpc.AssetRates{
SubjectAssetRate: rpcSubjectAssetToBtcRate,
PaymentAssetRate: rpcPaymentAssetToBtcRate,
ExpiryTimestamp: uint64(expiry),
}, nil
}
// QueryAssetRates queries the asset rates for a given transaction type, subject
// asset, and payment asset. An asset rate is the number of asset units per
// BTC.
//
// Example use case:
//
// Alice is trying to pay an invoice by spending an asset. Alice therefore
// requests that Bob (her asset channel counterparty) purchase the asset from
// her. Bob's payment, in BTC, will pay the invoice.
//
// Alice requests a bid quote from Bob. Her request includes an asset rates hint
// (ask). Alice obtains the asset rates hint by calling this endpoint. She sets:
// - `SubjectAsset` to the asset she is trying to sell.
// - `SubjectAssetMaxAmount` to the max channel asset outbound.
// - `PaymentAsset` to BTC.
// - `TransactionType` to SALE.
// - `AssetRateHint` to nil.
//
// Bob calls this endpoint to get the bid quote asset rates that he will send as
// a response to Alice's request. He sets:
// - `SubjectAsset` to the asset that Alice is trying to sell.
// - `SubjectAssetMaxAmount` to the value given in Alice's quote request.
// - `PaymentAsset` to BTC.
// - `TransactionType` to PURCHASE.
// - `AssetRateHint` to the value given in Alice's quote request.
func (o *oracleHarness) QueryAssetRates(_ context.Context,
req *oraclerpc.QueryAssetRatesRequest) (
*oraclerpc.QueryAssetRatesResponse, error) {
// Ensure that the payment asset is BTC. We only support BTC as the
// payment asset in this example.
if !rpcutils.IsAssetBtc(req.PaymentAsset) {
log.Infof("Payment asset is not BTC: %v", req.PaymentAsset)
return &oraclerpc.QueryAssetRatesResponse{
Result: &oraclerpc.QueryAssetRatesResponse_Error{
Error: &oraclerpc.QueryAssetRatesErrResponse{
Message: "unsupported payment asset, " +
"only BTC is supported",
},
},
}, nil
}
// Ensure that the subject asset is set correctly.
subjectAssetID, err := parseSubjectAsset(req.SubjectAsset)
if err != nil {
log.Errorf("Error parsing subject asset: %v", err)
return nil, fmt.Errorf("error parsing subject asset: %w", err)
}
_, hasPurchase := o.purchasePrices[subjectAssetID]
_, hasSale := o.salePrices[subjectAssetID]
log.Infof("Have for asset=%x, purchase=%v, sale=%v", subjectAssetID[:],
hasPurchase, hasSale)
// Ensure that the subject asset is supported.
if !hasPurchase || !hasSale {
log.Infof("Unsupported subject asset ID str: %v\n",
req.SubjectAsset)
return &oraclerpc.QueryAssetRatesResponse{
Result: &oraclerpc.QueryAssetRatesResponse_Error{
Error: &oraclerpc.QueryAssetRatesErrResponse{
Message: "unsupported subject asset",
},
},
}, nil
}
assetRates, err := o.getAssetRates(subjectAssetID, req.TransactionType)
if err != nil {
return nil, err
}
log.Infof("QueryAssetRates returning rates (subject_asset_rate=%v, "+
"payment_asset_rate=%v)", assetRates.SubjectAssetRate,
assetRates.PaymentAssetRate)
return &oraclerpc.QueryAssetRatesResponse{
Result: &oraclerpc.QueryAssetRatesResponse_Ok{
Ok: &oraclerpc.QueryAssetRatesOkResponse{
AssetRates: &assetRates,
},
},
}, nil
}
// parseSubjectAsset parses the subject asset from the given asset specifier.
func parseSubjectAsset(subjectAsset *oraclerpc.AssetSpecifier) (asset.ID,
error) {
// Ensure that the subject asset is set.
if subjectAsset == nil {
return asset.ID{}, fmt.Errorf("subject asset is not set (nil)")
}
// Check the subject asset bytes if set.
var subjectAssetID asset.ID
switch {
case len(subjectAsset.GetAssetId()) > 0:
copy(subjectAssetID[:], subjectAsset.GetAssetId())
case len(subjectAsset.GetAssetIdStr()) > 0:
assetIDBytes, err := hex.DecodeString(
subjectAsset.GetAssetIdStr(),
)
if err != nil {
return asset.ID{}, fmt.Errorf("error decoding asset "+
"ID hex string: %w", err)
}
copy(subjectAssetID[:], assetIDBytes)
default:
return asset.ID{}, fmt.Errorf("subject asset ID bytes and ID " +
"str not set")
}
return subjectAssetID, nil
}
// generateSelfSignedCert generates a self-signed TLS certificate and private
// key.
func generateSelfSignedCert() (tls.Certificate, error) {
certBytes, keyBytes, err := cert.GenCertPair(
"itest price oracle", nil, nil, false, 24*time.Hour,
)
if err != nil {
return tls.Certificate{}, err
}
tlsCert, err := tls.X509KeyPair(certBytes, keyBytes)
if err != nil {
return tls.Certificate{}, err
}
return tlsCert, nil
}

View file

@ -129,12 +129,6 @@ type testCase struct {
test func(ctx context.Context, net *NetworkHarness,
t *harnessTest)
noAliceBob bool
// backwardCompat is a map of node names to the version they are going
// to be downgraded to during the specific test. Make sure to update the
// LITD_COMPAT_VERSIONS variable in the Makefile to include all versions
// used for any backward compatibility tests.
backwardCompat map[string]string
}
// waitForNTxsInMempool polls until finding the desired number of transactions

View file

@ -34,7 +34,6 @@ exception_list=(
# Exclude the tools Dockerfile as otherwise the linter may need to be
# considered every time the Go version is updated.
"./tools/Dockerfile"
"./itest/backward-compat"
)
# is_exception checks if a file is in the exception list.

View file

@ -64,9 +64,7 @@ fi
target_go_version="$1"
# File paths to be excluded from the check.
exception_list=(
"./itest/backward-compat"
)
exception_list=()
# is_exception checks if a file is in the exception list.
is_exception() {

View file

@ -1,80 +0,0 @@
#!/bin/bash
# Build and install older versions of `litd` for backward compatibility
# integration tests.
#
# Usage:
# ./scripts/install-backward-compat-versions.sh "<version1> <version2> ..."
#
# Example:
# ./scripts/install-backward-compat-versions.sh "v0.12.0-beta v0.14.1-alpha"
#
# Parameters:
# $1 Space-separated list of `litd` versions to install (required).
#
# Environment Variables:
# REPO_URL URL of the litd repository (defaults to:
# https://github.com/lightninglabs/lightning-terminal.git)
#
# Notes:
# - Each version will be installed under a version-specific path.
set -ex
VERSIONS="$1"
REPO_URL="${REPO_URL:-https://github.com/lightninglabs/lightning-terminal.git}"
# Make sure at least one version is set.
if [[ -z "${VERSIONS}" ]]; then
echo "Usage: $0 '<version1> <version2> ...'"
echo "Please provide at least one version to install."
exit 1
fi
# Directory of the script file, independent of where it's called from.
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ITEST_DIR="${DIR}/../itest"
TARGET_DIR="${ITEST_DIR}/backward-compat"
mkdir -p "${TARGET_DIR}" && cd "${TARGET_DIR}"
# First, make sure we've cloned each version of litd.
for VERSION in ${VERSIONS}; do
VERSION_DIR="${TARGET_DIR}/litd-${VERSION}"
# Check if the version is already installed.
if [[ -f "${VERSION_DIR}/Makefile" ]]; then
echo "Version ${VERSION} is already installed."
continue
fi
# Clone the specified version of litd.
echo "Installing litd ${VERSION} to ${VERSION_DIR}..."
git clone ${REPO_URL} --depth 1 -b "$VERSION" "${VERSION_DIR}"
done
# Build the itest binary for each version.
for VERSION in ${VERSIONS}; do
VERSION_DIR="${TARGET_DIR}/litd-${VERSION}"
SRC="${VERSION_DIR}/itest/litd-itest"
DST="${ITEST_DIR}/litd-itest-${VERSION}"
if [[ -f "${DST}" ]]; then
echo "Binary ${DST} is already available, skipping build."
continue
fi
echo "Building litd ${VERSION}..."
cd "${VERSION_DIR}"
# The Makefile was changed a bit, but the "itest-only" target that skips the
# frontend build has existed for a while. We use it to build the itest binary
# (but don't actually run the tests).
make itest-only icase=nothing
# Copy the resulting binary to the main itest directory.
echo "Copying ${SRC} to ${DST}"
cp "${SRC}" "${DST}"
done