-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3dae35
commit 219d0da
Showing
5 changed files
with
101 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/smartcontractkit/chainlink-solana | ||
|
||
go 1.22.0 | ||
go 1.23 | ||
|
||
toolchain go1.23.1 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package logpoller | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/gagliardetto/solana-go" | ||
"github.com/google/uuid" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func newRandomFilter(t *testing.T) Filter { | ||
return Filter{ | ||
Name: uuid.NewString(), | ||
Address: newRandomPublicKey(t), | ||
EventName: "event", | ||
EventSig: newRandomEventSignature(t), | ||
StartingBlock: 1, | ||
EventIDL: "{}", | ||
SubkeyPaths: [][]string{{"a", "b"}, {"c"}}, | ||
Retention: 1000, | ||
MaxLogsKept: 3, | ||
} | ||
} | ||
|
||
func newRandomPublicKey(t *testing.T) PublicKey { | ||
privateKey, err := solana.NewRandomPrivateKey() | ||
require.NoError(t, err) | ||
pubKey := privateKey.PublicKey() | ||
return PublicKey(pubKey) | ||
} | ||
|
||
func newRandomEventSignature(t *testing.T) EventSignature { | ||
pubKey := newRandomPublicKey(t) | ||
return EventSignature(pubKey[:8]) | ||
} | ||
|
||
func newRandomLog(t *testing.T, filterID int64, chainID string) Log { | ||
privateKey, err := solana.NewRandomPrivateKey() | ||
require.NoError(t, err) | ||
pubKey := privateKey.PublicKey() | ||
data := []byte("solana is fun") | ||
signature, err := privateKey.Sign(data) | ||
require.NoError(t, err) | ||
return Log{ | ||
FilterId: filterID, | ||
ChainId: chainID, | ||
LogIndex: 1, | ||
BlockHash: Hash(pubKey), | ||
BlockNumber: 10, | ||
BlockTimestamp: time.Unix(1731590113, 0), | ||
Address: PublicKey(pubKey), | ||
EventSig: EventSignature{3, 2, 1}, | ||
SubkeyValues: [][]byte{{3, 2, 1}, {1}, {1, 2}, pubKey.Bytes()}, | ||
TxHash: Signature(signature), | ||
Data: data, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters