Skip to content

Commit d4ec013

Browse files
committed
loadtest: change asset type for sendtest to string
1 parent d5fbf31 commit d4ec013

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

itest/loadtest/config.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
"github.com/btcsuite/btcd/chaincfg"
88
"github.com/jessevdk/go-flags"
9-
"github.com/lightninglabs/taproot-assets/taprpc"
109
)
1110

1211
const (
@@ -111,9 +110,10 @@ type Config struct {
111110
// This is only relevant for the send test.
112111
NumAssets uint64 `long:"send-test-num-assets" description:"the number of assets to send in each send operation; only relevant for the send test"`
113112

114-
// SendType is the type of asset to attempt to send. This is only
115-
// relevant for the send test.
116-
SendType taprpc.AssetType `long:"send-test-send-type" description:"the type of asset to attempt to send; only relevant for the send test"`
113+
// SendAssetType is the type of asset to attempt to send. This is only
114+
// relevant for the send test. Acceptable values are "normal" and
115+
// "collectible".
116+
SendAssetType string `long:"send-asset-type" description:"the type of asset to attempt to send; only relevant for the send test"`
117117

118118
// TestSuiteTimeout is the timeout for the entire test suite.
119119
TestSuiteTimeout time.Duration `long:"test-suite-timeout" description:"the timeout for the entire test suite"`
@@ -143,8 +143,8 @@ func DefaultConfig() Config {
143143
Network: "regtest",
144144
BatchSize: 100,
145145
NumSends: 50,
146-
NumAssets: 1, // We only mint collectibles.
147-
SendType: taprpc.AssetType_COLLECTIBLE,
146+
NumAssets: 1,
147+
SendAssetType: "normal",
148148
TestSuiteTimeout: defaultSuiteTimeout,
149149
TestTimeout: defaultTestTimeout,
150150
PrometheusGateway: &PrometheusGatewayConfig{

itest/loadtest/loadtest-sample.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ send-test-num-sends=5
2222
# Number of assets to send in each send operation for send test
2323
send-test-num-assets=1
2424

25+
# Type of asset to use in the test case. For V2 test cases, a "normal" type is
26+
# required.
27+
send-asset-type="normal"
28+
2529
# Timeout for the entire test suite
2630
test-suite-timeout=120m
2731

itest/loadtest/send_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,24 @@ func sendTest(t *testing.T, ctx context.Context, cfg *Config) {
2929
ctxt, cancel := context.WithTimeout(ctxb, cfg.TestTimeout)
3030
defer cancel()
3131

32+
sendType := stringToAssetType(cfg.SendAssetType)
33+
3234
t.Logf("Running send test, sending %d asset(s) of type %v %d times",
33-
cfg.NumAssets, cfg.SendType, cfg.NumSends)
35+
cfg.NumAssets, sendType, cfg.NumSends)
3436
for i := 1; i <= cfg.NumSends; i++ {
3537
send, receive, ok := pickSendNode(
36-
t, ctx, cfg.NumAssets, cfg.SendType, alice, bob,
38+
t, ctx, cfg.NumAssets, sendType, alice, bob,
3739
)
3840
if !ok {
3941
t.Fatalf("Aborting send test at attempt %d of %d as "+
4042
"no node has enough balance to send %d "+
4143
"assets of type %v", i, cfg.NumSends,
42-
cfg.NumAssets, cfg.SendType)
44+
cfg.NumAssets, sendType)
4345
return
4446
}
4547

4648
sendAssets(
47-
t, ctxt, cfg.NumAssets, cfg.SendType, send, receive,
49+
t, ctxt, cfg.NumAssets, sendType, send, receive,
4850
bitcoinClient, cfg.TestTimeout,
4951
)
5052

itest/loadtest/utils.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,3 +289,15 @@ func getBitcoinConn(t *testing.T, cfg *BitcoinConfig) *rpcclient.Client {
289289

290290
return client
291291
}
292+
293+
// stringToAssetType converts a string of an asset type to its respective taprpc
294+
// type enum value.
295+
func stringToAssetType(t string) taprpc.AssetType {
296+
switch t {
297+
case "collectible":
298+
return taprpc.AssetType_COLLECTIBLE
299+
300+
default:
301+
return taprpc.AssetType_NORMAL
302+
}
303+
}

0 commit comments

Comments
 (0)