Skip to content

Commit

Permalink
eth tests
Browse files Browse the repository at this point in the history
Signed-off-by: Philip-21 <[email protected]>
  • Loading branch information
Philip-21 committed Feb 1, 2024
1 parent 2a29589 commit 0080595
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 19 deletions.
23 changes: 23 additions & 0 deletions internal/blockchain/ethereum/accounts_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package ethereum

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestCreateWalletFile(t *testing.T) {
dir := "walletdata"

prefix := "WalletPair"
outputDirectory := dir + "wallet.json"
password := "26371628355334###"
t.Run("TestCreateWalletFile", func(t *testing.T) {
keypair, filename, err := CreateWalletFile(outputDirectory, prefix, password)
if err != nil {
t.Logf("unable to create wallet file %v: ", err)
}
assert.NotNil(t, keypair)
assert.NotNil(t, filename)
})
}
33 changes: 33 additions & 0 deletions internal/blockchain/ethereum/contracts_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package ethereum

import (
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
)

func TestReadTruffleCompiledContract(t *testing.T) {
dir := "testdata"
contracFile := filepath.Join(dir, "truffle.json")

t.Run("TestTruffleCompilesContract", func(t *testing.T) {
ExpectedContractName := "FireFly_Client"

compiledContracts, err := ReadTruffleCompiledContract(contracFile)
if err != nil {
t.Logf("unable to read truffle contract : %v", err)
}
contractMap := compiledContracts.Contracts
assert.NotNil(t, compiledContracts)
assert.NotNil(t, contractMap)

contractName, ok := contractMap[ExpectedContractName]
assert.True(t, ok, "Expected contract '%s' not found", ExpectedContractName)
assert.NotNil(t, contractName)
})
}

func TestReadSolCompiledContract(t *testing.T){

}
19 changes: 0 additions & 19 deletions internal/blockchain/ethereum/ethsigner/accounts_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package ethsigner

import (
"context"
"testing"

"github.com/hyperledger/firefly-cli/internal/log"
"github.com/stretchr/testify/assert"
)

Expand All @@ -23,20 +21,3 @@ func TestWriteTomlKeyFile(t *testing.T) {
})

}

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)
}
})

}
48 changes: 48 additions & 0 deletions internal/blockchain/ethereum/testdata/truffle.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"abi": [
{
"constant": false,
"inputs": [
{
"name": "_value",
"type": "uint256"
}
],
"name": "setValue",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getValue",
"outputs": [
{
"name": "transaction",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getOwner",
"outputs": [
{
"name": "hyperledger_client",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
],
"bytecode": "0x60606033445566778899aabbccddeeff00112233445566778899aabbccddeeff",
"contractName": "FireFly_Client"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"address":"0c424d6735b5967822c9debc2f1cc6c8081feb1b","id":"2f59b024-bfff-460c-956a-89b1075279e3","version":3,"crypto":{"cipher":"aes-128-ctr","ciphertext":"7faf7ebbd2ed1856926ba0ab00d6d427ce8330313406fb6661641bad50ff17ab","cipherparams":{"iv":"7a5f74a730d5dbe72fac1eca14ec0024"},"kdf":"scrypt","mac":"5189f9702c3bb3b55464f59915c828a23f3915b5a5bfb49ce3ea558833eed65e","kdfparams":{"dklen":32,"n":1024,"p":1,"r":8,"salt":"96f8e96fbabb2ed7d69eebc5cd8b91234f0c48edbc3ede7d6be2fd1d968e8d6b"}}}

0 comments on commit 0080595

Please sign in to comment.