-
Notifications
You must be signed in to change notification settings - Fork 2k
[PLEX - 3187] - Stellar LOOP Relayer setup + core node cmds #22902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ilija42
wants to merge
20
commits into
develop
Choose a base branch
from
PLEX-3187-stellar-relayer-setup
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b51308a
Add stellar to relayer factory
ilija42 20f647f
Add stellar keystore to orm
ilija42 c68cf43
Register Stellar as a LOOP
ilija42 7403d99
run generate
ilija42 2daa7fe
Cleanup stellar core node cmds
ilija42 6ef7878
lint
ilija42 175c27a
update TestCoreRelayerChainInteroperators with stellar
ilija42 4c367d0
rm stray test file
ilija42 1addc88
lint
ilija42 f4796a4
lint
ilija42 2a99bff
lint
ilija42 9c3fdb7
tm bad test parallel execution
ilija42 352327f
supress lint on parallel test
ilija42 776ceca
lint
ilija42 8739f73
lint
ilija42 98204bc
Fix NewStellarKeyResources key slice init
ilija42 0687730
lint
ilija42 1436359
goimports
ilija42 58c9318
lint
ilija42 35278dc
lint
ilija42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 cmd | ||
|
|
||
| import ( | ||
| "github.com/smartcontractkit/chainlink-common/keystore/corekeys/stellarkey" | ||
| "github.com/smartcontractkit/chainlink-common/pkg/utils" | ||
|
|
||
| "github.com/smartcontractkit/chainlink/v2/core/web/presenters" | ||
| ) | ||
|
|
||
| type StellarKeyPresenter struct { | ||
| JAID | ||
| presenters.StellarKeyResource | ||
| } | ||
|
|
||
| // RenderTable implements TableRenderer | ||
| func (p StellarKeyPresenter) RenderTable(rt RendererTable) error { | ||
| headers := []string{"ID", "Stellar Public Key"} | ||
| rows := [][]string{p.ToRow()} | ||
|
|
||
| if _, err := rt.Write([]byte("🔑 Stellar Keys\n")); err != nil { | ||
| return err | ||
| } | ||
| renderList(headers, rows, rt.Writer) | ||
|
|
||
| return utils.JustError(rt.Write([]byte("\n"))) | ||
| } | ||
|
|
||
| func (p *StellarKeyPresenter) ToRow() []string { | ||
| row := []string{ | ||
| p.ID, | ||
| p.PubKey, | ||
| } | ||
|
|
||
| return row | ||
| } | ||
|
|
||
| type StellarKeyPresenters []StellarKeyPresenter | ||
|
|
||
| // RenderTable implements TableRenderer | ||
| func (ps StellarKeyPresenters) RenderTable(rt RendererTable) error { | ||
| headers := []string{"ID", "Stellar Public Key"} | ||
| rows := make([][]string, 0, len(ps)) | ||
|
|
||
| for _, p := range ps { | ||
| rows = append(rows, p.ToRow()) | ||
| } | ||
|
|
||
| if _, err := rt.Write([]byte("🔑 Stellar Keys\n")); err != nil { | ||
| return err | ||
| } | ||
| renderList(headers, rows, rt.Writer) | ||
|
|
||
| return utils.JustError(rt.Write([]byte("\n"))) | ||
| } | ||
|
|
||
| func NewStellarKeysClient(s *Shell) KeysClient { | ||
| return newKeysClient[stellarkey.Key, StellarKeyPresenter, StellarKeyPresenters]("Stellar", s) | ||
| } | ||
This file contains hidden or 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,179 @@ | ||
| package cmd_test | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "context" | ||
| "flag" | ||
| "os" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| "github.com/urfave/cli" | ||
|
|
||
| "github.com/smartcontractkit/chainlink-common/keystore/corekeys/stellarkey" | ||
| "github.com/smartcontractkit/chainlink-common/pkg/utils" | ||
|
|
||
| "github.com/smartcontractkit/chainlink/v2/core/cmd" | ||
| "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" | ||
|
ilija42 marked this conversation as resolved.
|
||
| "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" | ||
| "github.com/smartcontractkit/chainlink/v2/core/web/presenters" | ||
| ) | ||
|
|
||
| func TestStellarKeyPresenter_RenderTable(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| var ( | ||
| id = "GDTERXGZ7J6NQCSTG7ZNDR7RYV6QD2K4U4XG7K6Y4GD5EQLNMXS6K4C5" | ||
| pubKey = "somepubkey" | ||
| buffer = bytes.NewBufferString("") | ||
| r = cmd.RendererTable{Writer: buffer} | ||
| ) | ||
|
|
||
| p := cmd.StellarKeyPresenter{ | ||
| JAID: cmd.JAID{ID: id}, | ||
| StellarKeyResource: presenters.StellarKeyResource{ | ||
| JAID: presenters.NewJAID(id), | ||
| PubKey: pubKey, | ||
| }, | ||
| } | ||
|
|
||
| // Render a single resource | ||
| require.NoError(t, p.RenderTable(r)) | ||
|
|
||
| output := buffer.String() | ||
| assert.Contains(t, output, id) | ||
| assert.Contains(t, output, pubKey) | ||
|
|
||
| // Render many resources | ||
| buffer.Reset() | ||
| ps := cmd.StellarKeyPresenters{p} | ||
| require.NoError(t, ps.RenderTable(r)) | ||
|
|
||
| output = buffer.String() | ||
| assert.Contains(t, output, id) | ||
| assert.Contains(t, output, pubKey) | ||
| } | ||
|
|
||
| //nolint:paralleltest // subtests share a single keystore/application instance | ||
| func TestShell_StellarKeys(t *testing.T) { | ||
| app := startNewApplicationV2(t, nil) | ||
|
ilija42 marked this conversation as resolved.
|
||
| ks := app.GetKeyStore().Stellar() | ||
| cleanup := func() { | ||
| ctx := context.Background() | ||
| keys, err := ks.GetAll() | ||
| require.NoError(t, err) | ||
| for _, key := range keys { | ||
| require.NoError(t, utils.JustError(ks.Delete(ctx, key.ID()))) | ||
| } | ||
| requireStellarKeyCount(t, app, 0) | ||
| } | ||
|
|
||
| //nolint:paralleltest // subtests share a single keystore/application instance | ||
| t.Run("ListStellarKeys", func(tt *testing.T) { | ||
| defer cleanup() | ||
| ctx := tt.Context() | ||
|
ilija42 marked this conversation as resolved.
|
||
| client, r := app.NewShellAndRenderer() | ||
| key, err := app.GetKeyStore().Stellar().Create(ctx) | ||
| require.NoError(t, err) | ||
| requireStellarKeyCount(t, app, 1) | ||
| require.NoError(t, cmd.NewStellarKeysClient(client).ListKeys(cltest.EmptyCLIContext())) | ||
| require.Len(t, r.Renders, 1) | ||
| keys := *r.Renders[0].(*cmd.StellarKeyPresenters) | ||
| assert.Equal(t, key.PublicKeyStr(), keys[0].PubKey) | ||
| }) | ||
|
|
||
| //nolint:paralleltest // subtests share a single keystore/application instance | ||
| t.Run("CreateStellarKey", func(tt *testing.T) { | ||
| defer cleanup() | ||
| client, _ := app.NewShellAndRenderer() | ||
|
ilija42 marked this conversation as resolved.
|
||
| require.NoError(t, cmd.NewStellarKeysClient(client).CreateKey(nilContext)) | ||
| keys, err := app.GetKeyStore().Stellar().GetAll() | ||
| require.NoError(t, err) | ||
| require.Len(t, keys, 1) | ||
| }) | ||
|
|
||
| //nolint:paralleltest // subtests share a single keystore/application instance | ||
| t.Run("DeleteStellarKey", func(tt *testing.T) { | ||
| defer cleanup() | ||
| ctx := tt.Context() | ||
|
ilija42 marked this conversation as resolved.
|
||
| client, _ := app.NewShellAndRenderer() | ||
| key, err := app.GetKeyStore().Stellar().Create(ctx) | ||
| require.NoError(t, err) | ||
| requireStellarKeyCount(t, app, 1) | ||
| set := flag.NewFlagSet("test", 0) | ||
| flagSetApplyFromAction(cmd.NewStellarKeysClient(client).DeleteKey, set, "stellar") | ||
|
|
||
| require.NoError(tt, set.Set("yes", "true")) | ||
|
|
||
| strID := key.ID() | ||
| err = set.Parse([]string{strID}) | ||
| require.NoError(t, err) | ||
| c := cli.NewContext(nil, set, nil) | ||
| err = cmd.NewStellarKeysClient(client).DeleteKey(c) | ||
| require.NoError(t, err) | ||
| requireStellarKeyCount(t, app, 0) | ||
| }) | ||
|
|
||
| //nolint:paralleltest // subtests share a single keystore/application instance | ||
| t.Run("ImportExportStellarKey", func(tt *testing.T) { | ||
| defer cleanup() | ||
| defer deleteKeyExportFile(t) | ||
|
ilija42 marked this conversation as resolved.
|
||
| ctx := tt.Context() | ||
| client, _ := app.NewShellAndRenderer() | ||
|
|
||
| _, err := app.GetKeyStore().Stellar().Create(ctx) | ||
| require.NoError(t, err) | ||
|
|
||
| keys := requireStellarKeyCount(t, app, 1) | ||
| key := keys[0] | ||
| keyName := keyNameForTest(t) | ||
|
|
||
| // Export test invalid id | ||
| set := flag.NewFlagSet("test Stellar export", 0) | ||
| flagSetApplyFromAction(cmd.NewStellarKeysClient(client).ExportKey, set, "stellar") | ||
|
|
||
| require.NoError(tt, set.Parse([]string{"0"})) | ||
| require.NoError(tt, set.Set("new-password", "../internal/fixtures/incorrect_password.txt")) | ||
| require.NoError(tt, set.Set("output", keyName)) | ||
|
|
||
| c := cli.NewContext(nil, set, nil) | ||
| err = cmd.NewStellarKeysClient(client).ExportKey(c) | ||
| require.Error(t, err, "Error exporting") | ||
| require.Error(t, utils.JustError(os.Stat(keyName))) | ||
|
|
||
| // Export test | ||
| set = flag.NewFlagSet("test Stellar export", 0) | ||
| flagSetApplyFromAction(cmd.NewStellarKeysClient(client).ExportKey, set, "stellar") | ||
|
|
||
| require.NoError(tt, set.Parse([]string{key.ID()})) | ||
| require.NoError(tt, set.Set("new-password", "../internal/fixtures/incorrect_password.txt")) | ||
| require.NoError(tt, set.Set("output", keyName)) | ||
|
|
||
| c = cli.NewContext(nil, set, nil) | ||
|
|
||
| require.NoError(t, cmd.NewStellarKeysClient(client).ExportKey(c)) | ||
| require.NoError(t, utils.JustError(os.Stat(keyName))) | ||
|
|
||
| require.NoError(t, utils.JustError(app.GetKeyStore().Stellar().Delete(ctx, key.ID()))) | ||
| requireStellarKeyCount(t, app, 0) | ||
|
|
||
| set = flag.NewFlagSet("test Stellar import", 0) | ||
| flagSetApplyFromAction(cmd.NewStellarKeysClient(client).ImportKey, set, "stellar") | ||
|
|
||
| require.NoError(tt, set.Parse([]string{keyName})) | ||
| require.NoError(tt, set.Set("old-password", "../internal/fixtures/incorrect_password.txt")) | ||
| c = cli.NewContext(nil, set, nil) | ||
| require.NoError(t, cmd.NewStellarKeysClient(client).ImportKey(c)) | ||
|
|
||
| requireStellarKeyCount(t, app, 1) | ||
| }) | ||
| } | ||
|
|
||
| func requireStellarKeyCount(t *testing.T, app chainlink.Application, length int) []stellarkey.Key { | ||
| t.Helper() | ||
| keys, err := app.GetKeyStore().Stellar().GetAll() | ||
| require.NoError(t, err) | ||
| require.Len(t, keys, length) | ||
| return keys | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.