From 2a29589f6ab08480cda9016b2bba9de5d68087ad Mon Sep 17 00:00:00 2001 From: Philip-21 Date: Wed, 31 Jan 2024 01:38:29 +0100 Subject: [PATCH] eth tests Signed-off-by: Philip-21 --- .../ethereum/ethsigner/accounts_test.go | 42 +++++++++++++++++++ .../ethereum/ethsigner/testdata/copy.toml | 0 .../ethsigner/testdata/wallet.toml.toml | 8 ++++ 3 files changed, 50 insertions(+) create mode 100644 internal/blockchain/ethereum/ethsigner/accounts_test.go create mode 100644 internal/blockchain/ethereum/ethsigner/testdata/copy.toml create mode 100644 internal/blockchain/ethereum/ethsigner/testdata/wallet.toml.toml diff --git a/internal/blockchain/ethereum/ethsigner/accounts_test.go b/internal/blockchain/ethereum/ethsigner/accounts_test.go new file mode 100644 index 00000000..e5690996 --- /dev/null +++ b/internal/blockchain/ethereum/ethsigner/accounts_test.go @@ -0,0 +1,42 @@ +package ethsigner + +import ( + "context" + "testing" + + "github.com/hyperledger/firefly-cli/internal/log" + "github.com/stretchr/testify/assert" +) + +func TestWriteTomlKeyFile(t *testing.T) { + t.Run("TestwriteTomlKeyFile", func(t *testing.T) { + directory := "testdata" + FilePath := directory + "/wallet.toml" + + p := &EthSignerProvider{} + + File, err := p.writeTomlKeyFile(FilePath) + if err != nil { + t.Fatalf("unable to write file: %v", err) + } + assert.NotNil(t, File) + }) + +} + +func TestCopyTomlFileToVolume(t *testing.T) { + t.Run("TestCopyTomltoVolume", func(t *testing.T) { + ctx := log.WithLogger(context.Background(), &log.StdoutLogger{}) + + directory := "testdata" + tomlPath := directory + "/copy.toml" + VolumeName := "ethsigner" + + p := &EthSignerProvider{} + err := p.copyTomlFileToVolume(ctx, tomlPath, VolumeName) + if err != nil { + t.Fatalf("unable to copy file: %v", err) + } + }) + +} \ No newline at end of file diff --git a/internal/blockchain/ethereum/ethsigner/testdata/copy.toml b/internal/blockchain/ethereum/ethsigner/testdata/copy.toml new file mode 100644 index 00000000..e69de29b diff --git a/internal/blockchain/ethereum/ethsigner/testdata/wallet.toml.toml b/internal/blockchain/ethereum/ethsigner/testdata/wallet.toml.toml new file mode 100644 index 00000000..83160fdd --- /dev/null +++ b/internal/blockchain/ethereum/ethsigner/testdata/wallet.toml.toml @@ -0,0 +1,8 @@ +[metadata] +createdAt = 2019-11-05T08:15:30-05:00 +description = "File based configuration" + +[signing] +type = "file-based-signer" +key-file = "/data/keystore/wallet.toml" +password-file = "/data/password"