Skip to content

Commit

Permalink
pkg/solana: bump multinode; update tx sender
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 committed Feb 3, 2025
1 parent c245a76 commit 073d707
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 130 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250128162345-af4c8fd4481a
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250128162345-af4c8fd4481a
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250127125541-a8fa42cc0f36
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250130175645-f9ffc7ee5eab
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250203183025-939526523893
github.com/smartcontractkit/libocr v0.0.0-20241223215956-e5b78d8e3919
github.com/stretchr/testify v1.10.0
go.uber.org/zap v1.27.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,8 @@ github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250128162345-a
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250128162345-af4c8fd4481a/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250127125541-a8fa42cc0f36 h1:dytZPggag6auyzmbhpIDmkHu7KrflIBEhLLec4/xFIk=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250127125541-a8fa42cc0f36/go.mod h1:Z2e1ynSJ4pg83b4Qldbmryc5lmnrI3ojOdg1FUloa68=
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250130175645-f9ffc7ee5eab h1:uJ5i/b3A4gewVhe7vGArKoT7vhtoFIKCy4ecI08vft4=
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250130175645-f9ffc7ee5eab/go.mod h1:4JqpgFy01LaqG1yM2iFTzwX3ZgcAvW9WdstBZQgPHzU=
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250203183025-939526523893 h1:hQEEpKrWRqZ//SkA/m1G5puVHK1mYhZzturgX7VsPhk=
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250203183025-939526523893/go.mod h1:4JqpgFy01LaqG1yM2iFTzwX3ZgcAvW9WdstBZQgPHzU=
github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 h1:12ijqMM9tvYVEm+nR826WsrNi6zCKpwBhuApq127wHs=
github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7/go.mod h1:FX7/bVdoep147QQhsOPkYsPEXhGZjeYx6lBSaSXtZOA=
github.com/smartcontractkit/libocr v0.0.0-20241223215956-e5b78d8e3919 h1:IpGoPTXpvllN38kT2z2j13sifJMz4nbHglidvop7mfg=
Expand Down
16 changes: 8 additions & 8 deletions integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ require (
github.com/lib/pq v1.10.9
github.com/pelletier/go-toml/v2 v2.2.3
github.com/rs/zerolog v1.33.0
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130104613-82e554262f7d
github.com/smartcontractkit/chainlink-solana v1.1.2-0.20250130175010-4757d15a0538
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130202959-6f1f48342e36
github.com/smartcontractkit/chainlink-solana v1.1.2-0.20250203214419-38982a7fc48b
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.21
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.10
github.com/smartcontractkit/chainlink/deployment v0.0.0-20250130175903-0e1f197a2743
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20250130175903-0e1f197a2743
github.com/smartcontractkit/chainlink/v2 v2.19.0-ccip1.5.16-alpha.0.0.20250130175903-0e1f197a2743
github.com/smartcontractkit/chainlink/deployment v0.0.0-20250203214543-d9da97d53b9b
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20250203214543-d9da97d53b9b
github.com/smartcontractkit/chainlink/v2 v2.19.0-ccip1.5.16-alpha.0.0.20250203214543-d9da97d53b9b
github.com/smartcontractkit/libocr v0.0.0-20241223215956-e5b78d8e3919
github.com/stretchr/testify v1.10.0
github.com/testcontainers/testcontainers-go v0.35.0
Expand Down Expand Up @@ -342,13 +342,13 @@ require (
github.com/slack-go/slack v0.15.0 // indirect
github.com/smartcontractkit/chain-selectors v1.0.37 // indirect
github.com/smartcontractkit/chainlink-automation v0.8.1 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203130001-13e2609047e9 // indirect
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250128162345-af4c8fd4481a // indirect
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20250130125138-3df261e09ddc // indirect
github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250128203428-08031923fbe5 // indirect
github.com/smartcontractkit/chainlink-feeds v0.1.1 // indirect
github.com/smartcontractkit/chainlink-framework/chains v0.0.0-20250124205858-500edf2db981 // indirect
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250130175645-f9ffc7ee5eab // indirect
github.com/smartcontractkit/chainlink-framework/chains v0.0.0-20250203160922-fbdf168bb92a // indirect
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250203183025-939526523893 // indirect
github.com/smartcontractkit/chainlink-protos/orchestrator v0.4.0 // indirect
github.com/smartcontractkit/chainlink-protos/svr v0.0.0-20250123084029-58cce9b32112 // indirect
github.com/smartcontractkit/chainlink-starknet/relayer v0.1.1-0.20250117224137-afdcdd75070d // indirect
Expand Down
28 changes: 14 additions & 14 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1227,22 +1227,22 @@ github.com/smartcontractkit/chain-selectors v1.0.37 h1:EKVl8wayhOVfnlqfVmEyZ8rXO
github.com/smartcontractkit/chain-selectors v1.0.37/go.mod h1:xsKM0aN3YGcQKTPRPDDtPx2l4mlTN1Djmg0VVXV40b8=
github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU=
github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49 h1:Y9mC8DCJQUjU7IwGi0FVsH2Q8ujv9Na8DLq1StsGbso=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203130001-13e2609047e9 h1:+/KEPuWctPObgOoEEBCnli1/H3XnjMdCY3Tn+J32XRM=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203130001-13e2609047e9/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250128162345-af4c8fd4481a h1:1MrD2OiP/CRfyBSwTQE66R1+gLWBgWcU/SYl/+DmZ/Y=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250128162345-af4c8fd4481a/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130104613-82e554262f7d h1:ez+JYyIJ7pUR0/OnnU3AIKaC0Re85qB2fkA1NfiAnuA=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130104613-82e554262f7d/go.mod h1:Z2e1ynSJ4pg83b4Qldbmryc5lmnrI3ojOdg1FUloa68=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130202959-6f1f48342e36 h1:bS51NFGHVjkCy7yu9L2Ss4sBsCW6jpa5GuhRAdWWxzM=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130202959-6f1f48342e36/go.mod h1:Z2e1ynSJ4pg83b4Qldbmryc5lmnrI3ojOdg1FUloa68=
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20250130125138-3df261e09ddc h1:WZERXv2hTYRA0NpWg79ci/ZZSxucmvkty39iUOV8d7I=
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20250130125138-3df261e09ddc/go.mod h1:2iGmU7fkVsy21Sw8D+OhtYekHLUlJKHzwePKcxIx3Ac=
github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250128203428-08031923fbe5 h1:CvDfgWoLoYPapOumE/UZCplfCu5oNmy9BuH+6V6+fJ8=
github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250128203428-08031923fbe5/go.mod h1:pDZagSGjs9U+l4YIFhveDznMHqxuuz+5vRxvVgpbdr8=
github.com/smartcontractkit/chainlink-feeds v0.1.1 h1:JzvUOM/OgGQA1sOqTXXl52R6AnNt+Wg64sVG+XSA49c=
github.com/smartcontractkit/chainlink-feeds v0.1.1/go.mod h1:55EZ94HlKCfAsUiKUTNI7QlE/3d3IwTlsU3YNa/nBb4=
github.com/smartcontractkit/chainlink-framework/chains v0.0.0-20250124205858-500edf2db981 h1:svbNog045hGmbE3q10y3ijV55IgaqZMqvSnWGCa0d5w=
github.com/smartcontractkit/chainlink-framework/chains v0.0.0-20250124205858-500edf2db981/go.mod h1:tHem58EihQh63kR2LlAOKDAs9Vbghf1dJKZRGy6LG8g=
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250130175645-f9ffc7ee5eab h1:uJ5i/b3A4gewVhe7vGArKoT7vhtoFIKCy4ecI08vft4=
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250130175645-f9ffc7ee5eab/go.mod h1:4JqpgFy01LaqG1yM2iFTzwX3ZgcAvW9WdstBZQgPHzU=
github.com/smartcontractkit/chainlink-framework/chains v0.0.0-20250203160922-fbdf168bb92a h1:fVtn9CDfoGF40FeqGwLvp9belfIw7VT3lgQTctFGP5E=
github.com/smartcontractkit/chainlink-framework/chains v0.0.0-20250203160922-fbdf168bb92a/go.mod h1:tHem58EihQh63kR2LlAOKDAs9Vbghf1dJKZRGy6LG8g=
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250203183025-939526523893 h1:hQEEpKrWRqZ//SkA/m1G5puVHK1mYhZzturgX7VsPhk=
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250203183025-939526523893/go.mod h1:4JqpgFy01LaqG1yM2iFTzwX3ZgcAvW9WdstBZQgPHzU=
github.com/smartcontractkit/chainlink-protos/orchestrator v0.4.0 h1:ZBat8EBvE2LpSQR9U1gEbRV6PfAkiFdINmQ8nVnXIAQ=
github.com/smartcontractkit/chainlink-protos/orchestrator v0.4.0/go.mod h1:m/A3lqD7ms/RsQ9BT5P2uceYY0QX5mIt4KQxT2G6qEo=
github.com/smartcontractkit/chainlink-protos/svr v0.0.0-20250123084029-58cce9b32112 h1:c77Gi/APraqwbBO8fbd/5JY2wW+MSIpYg8Uma9MEZFE=
Expand All @@ -1253,12 +1253,12 @@ github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.21 h1:1UYLu0QA
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.21/go.mod h1:y6pVvAT/R+YGocAqoQIat+AEaZz2Jdmj/0uUBmwvLCU=
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.10 h1:Yf+n3T/fnUWcYyfe7bsygV4sWAkNo0QhN58APJFIKIc=
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.10/go.mod h1:05duR85P8YHuIfIkA7sn2bvrhKo/pDpFKV2rliYHNOo=
github.com/smartcontractkit/chainlink/deployment v0.0.0-20250130175903-0e1f197a2743 h1:JeuAxQCyp8HrLA6SvdRoj+J9eRQ/Z3BT+OvN/3nth2Y=
github.com/smartcontractkit/chainlink/deployment v0.0.0-20250130175903-0e1f197a2743/go.mod h1:5xwpqb7l/IDdQoUp7tDwgpnlJc5aH/VZVCrXv5a6Mcw=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20250130175903-0e1f197a2743 h1:o5C3vXVogdqOk88R0TJOhPcTiFaUndhWbVaES7twXBY=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20250130175903-0e1f197a2743/go.mod h1:mPVkHdTOih49R4tvjKi0jNN8+doRcVQwAF78yDDNaN4=
github.com/smartcontractkit/chainlink/v2 v2.19.0-ccip1.5.16-alpha.0.0.20250130175903-0e1f197a2743 h1:B45ROwpRHc7DxtaPKhwZ1T7AAwm5lIlyyfzz8JdMdQE=
github.com/smartcontractkit/chainlink/v2 v2.19.0-ccip1.5.16-alpha.0.0.20250130175903-0e1f197a2743/go.mod h1:HF3lF0hSEBKOniN49LFfo+5ynoEtmbO+V9S2ubnTat4=
github.com/smartcontractkit/chainlink/deployment v0.0.0-20250203214543-d9da97d53b9b h1:CJbV0ra65AiR5K1GZpbXHyDcPtDP5j82U6RY1pDWpPg=
github.com/smartcontractkit/chainlink/deployment v0.0.0-20250203214543-d9da97d53b9b/go.mod h1:/9iouaqMDOAyPkHKFiYzzPL/5516U7mjp/t14XiN59I=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20250203214543-d9da97d53b9b h1:x3mtyzJAGovCmjawrmTHW4XHvchFjOXJtrL15OujeM0=
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20250203214543-d9da97d53b9b/go.mod h1:e/GI2DNI54CKvpTY6Wqq8fcpZ3xYztWv+ihG5CF1XUc=
github.com/smartcontractkit/chainlink/v2 v2.19.0-ccip1.5.16-alpha.0.0.20250203214543-d9da97d53b9b h1:fWFIcI6tzCzF3j2FBcbOGv3E7rfX0URmxI2zO3tFuXA=
github.com/smartcontractkit/chainlink/v2 v2.19.0-ccip1.5.16-alpha.0.0.20250203214543-d9da97d53b9b/go.mod h1:huBdm7XEfj6DniyGxYLxV7g41McNvkyUhPRQIO/yXko=
github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 h1:12ijqMM9tvYVEm+nR826WsrNi6zCKpwBhuApq127wHs=
github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7/go.mod h1:FX7/bVdoep147QQhsOPkYsPEXhGZjeYx6lBSaSXtZOA=
github.com/smartcontractkit/libocr v0.0.0-20241223215956-e5b78d8e3919 h1:IpGoPTXpvllN38kT2z2j13sifJMz4nbHglidvop7mfg=
Expand Down
15 changes: 7 additions & 8 deletions pkg/solana/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ type chain struct {

// if multiNode is enabled, the clientCache will not be used
multiNode *mn.MultiNode[mn.StringID, *client.MultiNodeClient]
txSender *mn.TransactionSender[*solanago.Transaction, *client.SendTxResult, mn.StringID, *client.MultiNodeClient]
txSender *mn.TransactionSender[*solanago.Transaction, solanago.Signature, mn.StringID, *client.MultiNodeClient]
multiClient *client.MultiClient

// tracking node chain id for verification
Expand Down Expand Up @@ -297,12 +297,14 @@ func newChain(id string, cfg *config.TOMLConfig, ks core.Keystore, lggr logger.L
mnCfg.DeathDeclarationDelay(),
)

txSender := mn.NewTransactionSender[*solanago.Transaction, *client.SendTxResult, mn.StringID, *client.MultiNodeClient](
txSender := mn.NewTransactionSender[*solanago.Transaction, solanago.Signature, mn.StringID, *client.MultiNodeClient](
lggr,
mn.StringID(id),
chainFamily,
multiNode,
client.NewSendTxResult,
func(err error) mn.SendTxReturnCode {
return client.ClassifySendError(nil, err)
},
0, // use the default value provided by the implementation
)

Expand All @@ -314,11 +316,8 @@ func newChain(id string, cfg *config.TOMLConfig, ks core.Keystore, lggr logger.L

// Send tx using MultiNode transaction sender
sendTx = func(ctx context.Context, tx *solanago.Transaction) (solanago.Signature, error) {
result := ch.txSender.SendTransaction(ctx, tx)
if result == nil {
return solanago.Signature{}, errors.New("tx sender returned nil result")
}
return result.Signature(), result.Error()
sig, _, err := ch.txSender.SendTransaction(ctx, tx)
return sig, err
}

tc = internal.NewLoader[client.ReaderWriter](func() (client.ReaderWriter, error) { return ch.multiNode.SelectRPC() })
Expand Down
118 changes: 55 additions & 63 deletions pkg/solana/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/smartcontractkit/chainlink-common/pkg/config"
"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/services/servicetest"
"github.com/smartcontractkit/chainlink-common/pkg/sqlutil/sqltest"
"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
mn "github.com/smartcontractkit/chainlink-framework/multinode"
Expand Down Expand Up @@ -357,25 +358,24 @@ func TestSolanaChain_MultiNode_GetClient(t *testing.T) {
testChain, err := newChain("devnet", cfg, nil, logger.Test(t), sqltest.NewNoOpDataSource())
require.NoError(t, err)

err = testChain.Start(tests.Context(t))
require.NoError(t, err)
defer func() {
closeErr := testChain.Close()
require.NoError(t, closeErr)
}()
servicetest.Run(t, testChain)

selectedClient, err := testChain.getClient()
assert.NoError(t, err)
var selectedClient client.ReaderWriter
require.Eventually(t, func() bool {
var cerr error
selectedClient, cerr = testChain.getClient()
return cerr == nil
}, time.Minute, time.Second, "failed to get a client")

id, err := selectedClient.ChainID(tests.Context(t))
assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, "devnet", id.String())
}

func TestChain_MultiNode_TransactionSender(t *testing.T) {
ctx := tests.Context(t)
url := client.SetupLocalSolNode(t)
lgr, _ := logger.TestObserved(t, zapcore.DebugLevel)
lgr := logger.Test(t)

// transaction parameters
sender, err := solana.NewRandomPrivateKey()
Expand All @@ -398,89 +398,81 @@ func TestChain_MultiNode_TransactionSender(t *testing.T) {
mkey := mocks.NewSimpleKeystore(t)
c, err := newChain("localnet", cfg, mkey, lgr, sqltest.NewNoOpDataSource())
require.NoError(t, err)
require.NoError(t, c.Start(ctx))
defer func() {
require.NoError(t, c.Close())
}()
servicetest.Run(t, c)

require.Eventually(t, func() bool {
_, err := c.getClient()
return err == nil
}, time.Minute, time.Second, "failed to get a client")

createTx := func(from solana.PrivateKey, to solana.PrivateKey) *solana.Transaction {
t.Run("successful transaction", func(t *testing.T) {
cl, err := c.getClient()
require.NoError(t, err)

hash, hashErr := cl.LatestBlockhash(tests.Context(t))
assert.NoError(t, hashErr)
require.NoError(t, hashErr)

tx, txErr := solana.NewTransaction(
[]solana.Instruction{
system.NewTransferInstruction(
1,
from.PublicKey(),
to.PublicKey(),
sender.PublicKey(),
receiver.PublicKey(),
).Build(),
},
hash.Value.Blockhash,
solana.TransactionPayer(from.PublicKey()),
solana.TransactionPayer(sender.PublicKey()),
)
assert.NoError(t, txErr)
require.NoError(t, txErr)
_, signErr := tx.Sign(
func(key solana.PublicKey) *solana.PrivateKey {
if from.PublicKey().Equals(key) {
return &from
if sender.PublicKey().Equals(key) {
return &sender
}
return nil
},
)
assert.NoError(t, signErr)
return tx
}

t.Run("successful transaction", func(t *testing.T) {
require.NoError(t, signErr)
// Send tx using transaction sender
result := c.txSender.SendTransaction(ctx, createTx(sender, receiver))
require.NotNil(t, result)
require.NoError(t, result.Error())
require.Equal(t, mn.Successful, result.Code())
require.NotEmpty(t, result.Signature())
sig, code, err := c.txSender.SendTransaction(ctx, tx)
require.NoError(t, err)
require.Equal(t, mn.Successful, code)
require.NotEmpty(t, sig)
})

t.Run("unsigned transaction error", func(t *testing.T) {
// create + sign transaction
unsignedTx := func(to solana.PublicKey) *solana.Transaction {
cl, err := c.getClient()
require.NoError(t, err)

hash, hashErr := cl.LatestBlockhash(tests.Context(t))
assert.NoError(t, hashErr)

tx, txErr := solana.NewTransaction(
[]solana.Instruction{
system.NewTransferInstruction(
1,
sender.PublicKey(),
to,
).Build(),
},
hash.Value.Blockhash,
solana.TransactionPayer(sender.PublicKey()),
)
assert.NoError(t, txErr)
return tx
}
cl, err := c.getClient()
require.NoError(t, err)

hash, hashErr := cl.LatestBlockhash(tests.Context(t))
assert.NoError(t, hashErr)

tx, txErr := solana.NewTransaction(
[]solana.Instruction{
system.NewTransferInstruction(
1,
sender.PublicKey(),
receiver.PublicKey(),
).Build(),
},
hash.Value.Blockhash,
solana.TransactionPayer(sender.PublicKey()),
)
assert.NoError(t, txErr)

// Send tx using transaction sender
result := c.txSender.SendTransaction(ctx, unsignedTx(receiver.PublicKey()))
require.NotNil(t, result)
require.Error(t, result.Error())
require.Equal(t, mn.Fatal, result.Code())
require.Empty(t, result.Signature())
sig, code, err := c.txSender.SendTransaction(ctx, tx)
require.Error(t, err)
require.Equal(t, mn.Fatal, code)
require.Empty(t, sig)
})

t.Run("empty transaction", func(t *testing.T) {
result := c.txSender.SendTransaction(ctx, &solana.Transaction{})
require.NotNil(t, result)
require.Error(t, result.Error())
require.Equal(t, mn.Fatal, result.Code())
require.Empty(t, result.Signature())
sig, code, err := c.txSender.SendTransaction(ctx, &solana.Transaction{})
require.Error(t, err)
require.Equal(t, mn.Fatal, code)
require.Empty(t, sig)
})
}

Expand Down
Loading

0 comments on commit 073d707

Please sign in to comment.