From b3ef993a5a20ce031c25c080f7a4fb240a4f5b46 Mon Sep 17 00:00:00 2001 From: stephengaudet Date: Fri, 4 Aug 2023 15:56:27 -0700 Subject: [PATCH 1/7] add cli test coverage --- integration_test/cli_test.go | 94 ++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/integration_test/cli_test.go b/integration_test/cli_test.go index 82deffc5..42c9dfa2 100644 --- a/integration_test/cli_test.go +++ b/integration_test/cli_test.go @@ -15,3 +15,97 @@ func TestCliList(t *testing.T) { assert.Nil(t, err) require.Contains(t, string(out), "tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb") } + +func TestCliUsage(t *testing.T) { + out, err := SignatoryCli() + assert.Nil(t, err) + require.Contains(t, string(out), "Usage:") + require.Contains(t, string(out), "signatory-cli [command]") + require.Contains(t, string(out), "completion Generate the autocompletion script for the specified shell") + require.Contains(t, string(out), "help Help about any command") + require.Contains(t, string(out), "import Import Tezos private keys (edsk..., spsk..., p2sk...)") + require.Contains(t, string(out), "ledger Ledger specific operations") + require.Contains(t, string(out), "list List public keys") + require.Contains(t, string(out), "list-ops Print possible operation types inside the `generic` request") + require.Contains(t, string(out), "list-requests Print possible request types") + require.Contains(t, string(out), "version Show signatory image version/release (short alias 'v')") +} + +// If/when Issue #425 is fixed, this test will break. to fix it, leverage the function in this package named "getAllOps" +func TestCliListOps(t *testing.T) { + out, err := SignatoryCli("list-ops") + assert.Nil(t, err) + require.Contains(t, string(out), "Possible operation types:") + require.Contains(t, string(out), "- activate_account") + require.Contains(t, string(out), "- ballot") + require.Contains(t, string(out), "- delegation") + require.Contains(t, string(out), "- double_baking_evidence") + require.Contains(t, string(out), "- double_endorsement_evidence") + require.Contains(t, string(out), "- double_preendorsement_evidence") + require.Contains(t, string(out), "- drain_delegate") + require.Contains(t, string(out), "- endorsement") + require.Contains(t, string(out), "- endorsement_with_slot") + require.Contains(t, string(out), "- failing_noop") + require.Contains(t, string(out), "- increase_paid_storage") + require.Contains(t, string(out), "- origination") + require.Contains(t, string(out), "- preendorsement") + require.Contains(t, string(out), "- proposals") + require.Contains(t, string(out), "- register_global_constant") + require.Contains(t, string(out), "- reveal") + require.Contains(t, string(out), "- seed_nonce_revelation") + require.Contains(t, string(out), "- set_deposits_limit") + require.Contains(t, string(out), "- transaction") + require.Contains(t, string(out), "- update_consensus_key") + require.Contains(t, string(out), "- vdf_revelation") +} + +func TestCliListRequests(t *testing.T) { + out, err := SignatoryCli("list-requests") + assert.Nil(t, err) + require.Contains(t, string(out), "Possible request types:") + require.Contains(t, string(out), "- block") + require.Contains(t, string(out), "- endorsement") + require.Contains(t, string(out), "- generic") + require.Contains(t, string(out), "- preendorsement") +} + +func TestCliHelp(t *testing.T) { + usage, err := SignatoryCli() + assert.Nil(t, err) + help, err := SignatoryCli("help") + assert.Nil(t, err) + require.Contains(t, string(help), string(usage)) +} + +func TestCliLedgerUsage(t *testing.T) { + out, err := SignatoryCli("ledger") + assert.Nil(t, err) + require.Contains(t, string(out), "Ledger specific operations") + require.Contains(t, string(out), "Usage:") + require.Contains(t, string(out), "signatory-cli ledger [command]") + require.Contains(t, string(out), "Available Commands:") + require.Contains(t, string(out), "deauthorize-baking Deuthorize a key") + require.Contains(t, string(out), "get-high-watermark Get high water mark") + require.Contains(t, string(out), "get-high-watermarks Get all high water marks and chain ID") + require.Contains(t, string(out), "list List connected Ledgers") + require.Contains(t, string(out), "set-high-watermark Set high water mark") + require.Contains(t, string(out), "setup-baking Authorize a key for baking") + require.Contains(t, string(out), "Use \"signatory-cli ledger [command] --help\" for more information about a command.") +} + +func TestCliLedgerList(t *testing.T) { + out, err := SignatoryCli("ledger", "-t", "tcp://speculos:9999", "list") + assert.Nil(t, err) + require.Contains(t, string(out), "Path: speculos:9999") + require.Contains(t, string(out), "ID:") + require.Contains(t, string(out), "Version:") +} + +func TestCliVersion(t *testing.T) { + v, err := SignatoryCli("v") + assert.Nil(t, err) + require.Contains(t, string(v), "Release Version: ") + require.Greater(t, len(v), len("Release Version: ")+4) + version, err := SignatoryCli("version") + require.Equal(t, v, version) +} From df1cb6e6f5dc05a4ced34e4e63e8c5c6898328b1 Mon Sep 17 00:00:00 2001 From: stephengaudet Date: Fri, 4 Aug 2023 16:01:07 -0700 Subject: [PATCH 2/7] a script for the test developer workstation --- integration_test/cover.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 integration_test/cover.sh diff --git a/integration_test/cover.sh b/integration_test/cover.sh new file mode 100755 index 00000000..b0a3e724 --- /dev/null +++ b/integration_test/cover.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +#this script is used on a test developer's workstation to get coverage info +#it works on macos + +rm -f covraw.txt +go tool covdata textfmt -i=./coverage -o covraw.txt +sed -i '' 's/\/go\/src\/github.com/github.com/g' covraw.txt +rm -f cov.txt +go tool cover -func covraw.txt -o cov.txt +cat cov.txt +rm -f cov.html +go tool cover -html covraw.txt -o cov.html +open cov.html From be2631e1870c103f5ea9d76ca3fe45db46f59833 Mon Sep 17 00:00:00 2001 From: stephengaudet Date: Fri, 4 Aug 2023 17:22:45 -0700 Subject: [PATCH 3/7] WIP adding GetPublicKey tests. needed a refactor --- integration_test/http.go | 75 +++++++++++++++++++++++++++ integration_test/vault_gcp_test.go | 3 ++ integration_test/vault_ledger_test.go | 4 ++ integration_test/watermark_test.go | 60 +++++++-------------- 4 files changed, 101 insertions(+), 41 deletions(-) create mode 100644 integration_test/http.go diff --git a/integration_test/http.go b/integration_test/http.go new file mode 100644 index 00000000..b6241fb1 --- /dev/null +++ b/integration_test/http.go @@ -0,0 +1,75 @@ +package integrationtest + +import ( + "bytes" + "encoding/json" + "io" + "net/http" + "strings" + "testing" + + "github.com/stretchr/testify/require" +) + +type SignSuccessResponse struct { + Signature string `json:"signature"` +} + +type SignFailureResponse struct { + Id string `json:"id"` + Kind string `json:"kind"` + Msg string `json:"msg"` +} + +func RequestSignature(pkh string, body string) (int, []byte) { + url := "http://localhost:6732/keys/" + pkh + reqbody := strings.NewReader(body) + client := &http.Client{} + req, err := http.NewRequest(http.MethodPost, url, reqbody) + if err != nil { + panic(err) + } + resp, err := client.Do(req) + if err != nil { + panic(err) + } + defer resp.Body.Close() + bytes, err := io.ReadAll(resp.Body) + if err != nil { + panic(err) + } + return resp.StatusCode, bytes +} + +type GetKeySuccessResponse struct { + PublicKey string `json:"public_key"` +} + +func getPublicKey(pkh string) (int, []byte) { + url := "http://localhost:6732/keys/" + pkh + client := &http.Client{} + req, err := http.NewRequest(http.MethodGet, url, nil) + if err != nil { + panic(err) + } + resp, err := client.Do(req) + if err != nil { + panic(err) + } + defer resp.Body.Close() + bytes, err := io.ReadAll(resp.Body) + if err != nil { + panic(err) + } + return resp.StatusCode, bytes +} + +func GetPublicKey(t *testing.T, pkh string, expect string) { + code, message := getPublicKey(pkh) + require.Equal(t, code, 200) + var r GetKeySuccessResponse + dec := json.NewDecoder(bytes.NewReader(message)) + err := dec.Decode(&r) + require.Nil(t, err) + require.Equal(t, expect, r.PublicKey) +} diff --git a/integration_test/vault_gcp_test.go b/integration_test/vault_gcp_test.go index f27debbd..e230c7bd 100644 --- a/integration_test/vault_gcp_test.go +++ b/integration_test/vault_gcp_test.go @@ -45,4 +45,7 @@ func TestGCPVault(t *testing.T) { out, err = OctezClient("transfer", "1", "from", tz3alias, "to", "alice", "--burn-cap", "0.06425") assert.NoError(t, err) require.Contains(t, string(out), "Operation successfully injected in the node") + + //TODO: the PK belongs in the .env that is, another github secret in both actions and dependabot sections + GetPublicKey(t, tz3, "p2pk67dAL3pTy1vgBKzFHQNxV5cvzVR5ynnojBtPegAGAPhS59B2CSV") } diff --git a/integration_test/vault_ledger_test.go b/integration_test/vault_ledger_test.go index 2fd6a28f..e5d84b0b 100644 --- a/integration_test/vault_ledger_test.go +++ b/integration_test/vault_ledger_test.go @@ -18,3 +18,7 @@ func TestLedgerVault(t *testing.T) { assert.NoError(t, err) require.Contains(t, string(out), "Operation successfully injected in the node") } + +func TestLedgerVaultGetPublicKey(t *testing.T) { + GetPublicKey(t, "tz1RVYaHiobUKXMfJ47F7Rjxx5tu3LC35WSA", "edpktsKqhvR7kXbRWD7yDgLSD7PZUXvjLqf9SFscXhL52pUStF5nQp") +} diff --git a/integration_test/watermark_test.go b/integration_test/watermark_test.go index 31e36ece..000d221e 100644 --- a/integration_test/watermark_test.go +++ b/integration_test/watermark_test.go @@ -3,10 +3,7 @@ package integrationtest import ( "bytes" "encoding/json" - "io" - "net/http" "os/exec" - "strings" "sync" "testing" @@ -48,8 +45,8 @@ var functionalTestCases = []functionalTestCase{ "\"11b3d79f99000000020130c1cb51f36daebee85fe99c04800a38e8133ffd2fa329cd4db35f32fe5bf5e30000000064277ae404b7528bb55c532567eb5a866e2a9e7d4e120d2627b4cfb58061756071d6f4a5630000002500000001020000000400000002000000040000000000000004ffffffff0000000400000006080966c1f5a955161345bc7d81ac205ebafc89f5977a5bc88e47ab1b6f8d791e5ae8b92d9bc0523b3e07848458e66dc4265e29f3c5d8007447862e2483fdad12000000003e9dad7a000000000002\"", }, expectedStatusCodes: []int{200, 409}, - expectedResponses: []any{SuccessResponse{Signature: "edsigu6FPqZdPhLNo5AGCkdscaiMdZXsiV5djxy1v2r89J1ZWfVfZ2UXJEcURSsx38JSHXtccr9o5yzJ46NL6mGEZbZ86fiJjuv"}, - []FailureResponse{{Id: "failure", Kind: "temporary", Msg: "watermark validation failed"}}}, + expectedResponses: []any{SignSuccessResponse{Signature: "edsigu6FPqZdPhLNo5AGCkdscaiMdZXsiV5djxy1v2r89J1ZWfVfZ2UXJEcURSsx38JSHXtccr9o5yzJ46NL6mGEZbZ86fiJjuv"}, + []SignFailureResponse{{Id: "failure", Kind: "temporary", Msg: "watermark validation failed"}}}, watermarkBefore: nil, watermarkAfter: watermarkFile{pkh: {"block": {Level: 2, Round: 0, Hash: "vh2i6wpkn9bGpw47r3RhnfHiCrLvzTvQT36AmEZNPPsKqcN7yecT"}}}, chainID: "NetXo5iVw1vBoxM", @@ -61,8 +58,8 @@ var functionalTestCases = []functionalTestCase{ "\"11b3d79f990000000701e6be95eec66c430c141a3bdd29f969b93e708ea1a9e12715ff8cb73ec206e1e70000000064277b5004e67efbd02ffea1e25925b7d385d4be010ba88ed58a782b91f619008d8f093eb60000002500000001020000000400000007000000040000000200000004ffffffff000000040000000550ab35f1928fb750579a4785809eb9e95708e6701beacbc3f9ec93f4b93bfde7d1eba261c619f58322994e3093b15cd1a0b2253ee0d19b477d4842c53bcb3f4d00000002a40d1a28000000000002\"", }, expectedStatusCodes: []int{200, 409}, - expectedResponses: []any{SuccessResponse{Signature: "edsigtbYeDN9n2VjpoCmPVt5tQBe6Y95wTPPpgtVTx3g2S4hQSwypcdBWm5s6gfTi567MFFpDqXPRmdUBo4VqseLZdZc8LWnvK9"}, - []FailureResponse{{Id: "failure", Kind: "temporary", Msg: "watermark validation failed"}}}, + expectedResponses: []any{SignSuccessResponse{Signature: "edsigtbYeDN9n2VjpoCmPVt5tQBe6Y95wTPPpgtVTx3g2S4hQSwypcdBWm5s6gfTi567MFFpDqXPRmdUBo4VqseLZdZc8LWnvK9"}, + []SignFailureResponse{{Id: "failure", Kind: "temporary", Msg: "watermark validation failed"}}}, watermarkBefore: watermarkFile{pkh: {"block": {Level: 6, Round: 0, Hash: "vh2i6wpkn9bGpw47r3RhnfHiCrLvzTvQT36AmEZNPPsKqcN7yecT"}}}, watermarkAfter: watermarkFile{pkh: {"block": {Level: 7, Round: 2, Hash: "vh2x7GpWVr8wSUE7HuAr5antYqgqzXFTDA4Wy6UUAMTzvNU1cnd4"}}}, chainID: "NetXo5iVw1vBoxM", @@ -74,8 +71,8 @@ var functionalTestCases = []functionalTestCase{ "\"11b3d79f99000000020130c1cb51f36daebee85fe99c04800a38e8133ffd2fa329cd4db35f32fe5bf5e30000000064277aa504683625c2445a4e9564bf710c5528fd99a7d150d2a2a323bc22ff9e2710da4f6d00000021000000010200000004000000020000000000000004ffffffff0000000400000000080966c1f5a955161345bc7d81ac205ebafc89f5977a5bc88e47ab1b6f8d791e5ae8b92d9bc0523b3e07848458e66dc4265e29f3c5d8007447862e2483fdad1200000000a40d1a28000000000002\"", }, expectedStatusCodes: []int{200, 200}, - expectedResponses: []any{SuccessResponse{Signature: "edsigu6FPqZdPhLNo5AGCkdscaiMdZXsiV5djxy1v2r89J1ZWfVfZ2UXJEcURSsx38JSHXtccr9o5yzJ46NL6mGEZbZ86fiJjuv"}, - SuccessResponse{Signature: "edsigu6FPqZdPhLNo5AGCkdscaiMdZXsiV5djxy1v2r89J1ZWfVfZ2UXJEcURSsx38JSHXtccr9o5yzJ46NL6mGEZbZ86fiJjuv"}}, + expectedResponses: []any{SignSuccessResponse{Signature: "edsigu6FPqZdPhLNo5AGCkdscaiMdZXsiV5djxy1v2r89J1ZWfVfZ2UXJEcURSsx38JSHXtccr9o5yzJ46NL6mGEZbZ86fiJjuv"}, + SignSuccessResponse{Signature: "edsigu6FPqZdPhLNo5AGCkdscaiMdZXsiV5djxy1v2r89J1ZWfVfZ2UXJEcURSsx38JSHXtccr9o5yzJ46NL6mGEZbZ86fiJjuv"}}, watermarkBefore: nil, watermarkAfter: watermarkFile{pkh: {"block": {Level: 2, Round: 0, Hash: "vh2i6wpkn9bGpw47r3RhnfHiCrLvzTvQT36AmEZNPPsKqcN7yecT"}}}, chainID: "NetXo5iVw1vBoxM", @@ -86,7 +83,7 @@ var functionalTestCases = []functionalTestCase{ "\"11b3d79f990000000701e6be95eec66c430c141a3bdd29f969b93e708ea1a9e12715ff8cb73ec206e1e70000000064277b2c040f461cefa3799f612ea7055449b42addee450a4a5269d983d6e3682c9f0d211500000021000000010200000004000000070000000000000004ffffffff000000040000000250ab35f1928fb750579a4785809eb9e95708e6701beacbc3f9ec93f4b93bfde7d1eba261c619f58322994e3093b15cd1a0b2253ee0d19b477d4842c53bcb3f4d00000002a40d1a28000000000002\"", }, expectedStatusCodes: []int{200}, - expectedResponses: []any{SuccessResponse{Signature: "edsigtbYeDN9n2VjpoCmPVt5tQBe6Y95wTPPpgtVTx3g2S4hQSwypcdBWm5s6gfTi567MFFpDqXPRmdUBo4VqseLZdZc8LWnvK9"}}, + expectedResponses: []any{SignSuccessResponse{Signature: "edsigtbYeDN9n2VjpoCmPVt5tQBe6Y95wTPPpgtVTx3g2S4hQSwypcdBWm5s6gfTi567MFFpDqXPRmdUBo4VqseLZdZc8LWnvK9"}}, watermarkBefore: watermarkFile{pkh: {"block": {Level: 6, Round: 3, Hash: "vh2i6wpkn9bGpw47r3RhnfHiCrLvzTvQT36AmEZNPPsKqcN7yecT"}}}, watermarkAfter: watermarkFile{pkh: {"block": {Level: 7, Round: 2, Hash: "vh2x7GpWVr8wSUE7HuAr5antYqgqzXFTDA4Wy6UUAMTzvNU1cnd4"}}}, chainID: "NetXo5iVw1vBoxM", @@ -97,7 +94,7 @@ var functionalTestCases = []functionalTestCase{ "\"11b3d79f990000000701e6be95eec66c430c141a3bdd29f969b93e708ea1a9e12715ff8cb73ec206e1e70000000064277b2c040f461cefa3799f612ea7055449b42addee450a4a5269d983d6e3682c9f0d211500000021000000010200000004000000070000000000000004ffffffff000000040000000250ab35f1928fb750579a4785809eb9e95708e6701beacbc3f9ec93f4b93bfde7d1eba261c619f58322994e3093b15cd1a0b2253ee0d19b477d4842c53bcb3f4d00000002a40d1a28000000000002\"", }, expectedStatusCodes: []int{409}, - expectedResponses: []any{[]FailureResponse{{Id: "failure", Kind: "temporary", Msg: "watermark validation failed"}}}, + expectedResponses: []any{[]SignFailureResponse{{Id: "failure", Kind: "temporary", Msg: "watermark validation failed"}}}, watermarkBefore: watermarkFile{pkh: {"block": {Level: 8, Round: 1, Hash: "vh2i6wpkn9bGpw47r3RhnfHiCrLvzTvQT36AmEZNPPsKqcN7yecT"}}}, watermarkAfter: watermarkFile{pkh: {"block": {Level: 8, Round: 1, Hash: "vh2i6wpkn9bGpw47r3RhnfHiCrLvzTvQT36AmEZNPPsKqcN7yecT"}}}, chainID: "NetXo5iVw1vBoxM", @@ -108,7 +105,7 @@ var functionalTestCases = []functionalTestCase{ "\"11b3d79f990000000701e6be95eec66c430c141a3bdd29f969b93e708ea1a9e12715ff8cb73ec206e1e70000000064277b2c040f461cefa3799f612ea7055449b42addee450a4a5269d983d6e3682c9f0d211500000021000000010200000004000000070000000000000004ffffffff000000040000000250ab35f1928fb750579a4785809eb9e95708e6701beacbc3f9ec93f4b93bfde7d1eba261c619f58322994e3093b15cd1a0b2253ee0d19b477d4842c53bcb3f4d00000002a40d1a28000000000002\"", }, expectedStatusCodes: []int{409}, - expectedResponses: []any{[]FailureResponse{{Id: "failure", Kind: "temporary", Msg: "watermark validation failed"}}}, + expectedResponses: []any{[]SignFailureResponse{{Id: "failure", Kind: "temporary", Msg: "watermark validation failed"}}}, watermarkBefore: watermarkFile{pkh: {"block": {Level: 7, Round: 3, Hash: "vh2i6wpkn9bGpw47r3RhnfHiCrLvzTvQT36AmEZNPPsKqcN7yecT"}}}, watermarkAfter: watermarkFile{pkh: {"block": {Level: 7, Round: 3, Hash: "vh2i6wpkn9bGpw47r3RhnfHiCrLvzTvQT36AmEZNPPsKqcN7yecT"}}}, chainID: "NetXo5iVw1vBoxM", @@ -121,9 +118,9 @@ var functionalTestCases = []functionalTestCase{ "\"13b3d79f9981ff3a903959741b102d579148d3b1ea56ad7bc77e102def5cc73c49c062217a1500040000002200000004fd5a576ce08fa0e87e7b41d373d04a2df8798b234c7a4f8483a1d839e0066c06\"", }, expectedStatusCodes: []int{200, 200, 200}, - expectedResponses: []any{SuccessResponse{Signature: "edsigtfHHgiTKBhZ4wzfZwCtLpWsS1q4pHR47YbhWHLzxmx95LpSQQXXC4nWhoHCp7ppEeC2eHw2Be7zjQrKwHvsmb8KyJcGf1b"}, - SuccessResponse{Signature: "edsigtjpdXbicHctbhx82tQKMYNFrwSimTkFj16iWo38jMSFB9gzxbyyAuKmX8detwLGp8CWDvHyFs5pcivpCSHrJVD4ZUWSb5r"}, - SuccessResponse{Signature: "edsigtfoBKBjfYYASaf194oQknF3r5eag81ihkErSSi1WPiV6qfrQjCFWomAbjG63PKaLoUvoNxqK4TCD4MLoJAFC6JtHwtBYYn"}}, + expectedResponses: []any{SignSuccessResponse{Signature: "edsigtfHHgiTKBhZ4wzfZwCtLpWsS1q4pHR47YbhWHLzxmx95LpSQQXXC4nWhoHCp7ppEeC2eHw2Be7zjQrKwHvsmb8KyJcGf1b"}, + SignSuccessResponse{Signature: "edsigtjpdXbicHctbhx82tQKMYNFrwSimTkFj16iWo38jMSFB9gzxbyyAuKmX8detwLGp8CWDvHyFs5pcivpCSHrJVD4ZUWSb5r"}, + SignSuccessResponse{Signature: "edsigtfoBKBjfYYASaf194oQknF3r5eag81ihkErSSi1WPiV6qfrQjCFWomAbjG63PKaLoUvoNxqK4TCD4MLoJAFC6JtHwtBYYn"}}, watermarkBefore: watermarkFile{pkh: {"block": {Level: 33, Round: 2, Hash: "vh2i6wpkn9bGpw47r3RhnfHiCrLvzTvQT36AmEZNPPsKqcN7yecT"}}}, watermarkAfter: watermarkFile{pkh: {"block": {Level: 34, Round: 4, Hash: "vh2E3QPN8R55XtdeZXsPtbgXErMeLcE5YbjDMcUzXsFByL97u5Qc"}, "endorsement": {Level: 34, Round: 4, Hash: "vh216VxjGyVK2XWEQ5gyFcAMLEqPzRKJijB6ZUybZjnwetdZp8Lm"}, @@ -138,9 +135,9 @@ var functionalTestCases = []functionalTestCase{ "\"11b3d79f99000000220181ff3a903959741b102d579148d3b1ea56ad7bc77e102def5cc73c49c062217a000000006427822b0480a2ea07609835343e53282a2e0d8ef20f54d6a7c1603d3874c2a2a7fceb3d3d00000021000000010200000004000000220000000000000004fffffffd000000040000000415b3aa8c735353cf4cde8aec00319d8922538fef77d44ee6780c8872bf63408bfd5a576ce08fa0e87e7b41d373d04a2df8798b234c7a4f8483a1d839e0066c0600000004a40d1a28000000000002\"", }, expectedStatusCodes: []int{200, 200, 200}, - expectedResponses: []any{SuccessResponse{Signature: "edsigtjpdXbicHctbhx82tQKMYNFrwSimTkFj16iWo38jMSFB9gzxbyyAuKmX8detwLGp8CWDvHyFs5pcivpCSHrJVD4ZUWSb5r"}, - SuccessResponse{Signature: "edsigtfoBKBjfYYASaf194oQknF3r5eag81ihkErSSi1WPiV6qfrQjCFWomAbjG63PKaLoUvoNxqK4TCD4MLoJAFC6JtHwtBYYn"}, - SuccessResponse{Signature: "edsigtfHHgiTKBhZ4wzfZwCtLpWsS1q4pHR47YbhWHLzxmx95LpSQQXXC4nWhoHCp7ppEeC2eHw2Be7zjQrKwHvsmb8KyJcGf1b"}}, + expectedResponses: []any{SignSuccessResponse{Signature: "edsigtjpdXbicHctbhx82tQKMYNFrwSimTkFj16iWo38jMSFB9gzxbyyAuKmX8detwLGp8CWDvHyFs5pcivpCSHrJVD4ZUWSb5r"}, + SignSuccessResponse{Signature: "edsigtfoBKBjfYYASaf194oQknF3r5eag81ihkErSSi1WPiV6qfrQjCFWomAbjG63PKaLoUvoNxqK4TCD4MLoJAFC6JtHwtBYYn"}, + SignSuccessResponse{Signature: "edsigtfHHgiTKBhZ4wzfZwCtLpWsS1q4pHR47YbhWHLzxmx95LpSQQXXC4nWhoHCp7ppEeC2eHw2Be7zjQrKwHvsmb8KyJcGf1b"}}, watermarkBefore: watermarkFile{pkh: {"block": {Level: 33, Round: 2, Hash: "vh2i6wpkn9bGpw47r3RhnfHiCrLvzTvQT36AmEZNPPsKqcN7yecT"}}}, watermarkAfter: watermarkFile{pkh: {"block": {Level: 34, Round: 4, Hash: "vh2E3QPN8R55XtdeZXsPtbgXErMeLcE5YbjDMcUzXsFByL97u5Qc"}, "endorsement": {Level: 34, Round: 4, Hash: "vh216VxjGyVK2XWEQ5gyFcAMLEqPzRKJijB6ZUybZjnwetdZp8Lm"}, @@ -160,16 +157,16 @@ func TestWatermark(t *testing.T) { restart_signatory() } for i, request := range test.signRequestBodies { - code, message := request_sign(request) + code, message := RequestSignature(pkh, request) require.Equal(t, test.expectedStatusCodes[i], code) if code == 200 { - var sr SuccessResponse + var sr SignSuccessResponse dec := json.NewDecoder(bytes.NewReader(message)) err := dec.Decode(&sr) require.Nil(t, err) assert.Equal(t, test.expectedResponses[i], sr) } else { - var fr []FailureResponse + var fr []SignFailureResponse dec := json.NewDecoder(bytes.NewReader(message)) err := dec.Decode(&fr) require.Nil(t, err) @@ -278,7 +275,7 @@ func TestWatermarkConcurrency(t *testing.T) { func request_sign_concurrent(request string) { defer wg.Done() - code, message := request_sign(request) + code, message := RequestSignature(pkh, request) mutex.Lock() { codes = append(codes, code) @@ -320,22 +317,3 @@ func read_watermark_file(chainId string) (out []byte) { } return } - -func request_sign(body string) (int, []byte) { - reqbody := strings.NewReader(body) - client := &http.Client{} - req, err := http.NewRequest(http.MethodPost, url, reqbody) - if err != nil { - panic(err) - } - resp, err := client.Do(req) - if err != nil { - panic(err) - } - defer resp.Body.Close() - bytes, err := io.ReadAll(resp.Body) - if err != nil { - panic(err) - } - return resp.StatusCode, bytes -} From b97f0cacde89536343365346ff61186e93b598ad Mon Sep 17 00:00:00 2001 From: stephengaudet Date: Tue, 8 Aug 2023 13:40:01 -0700 Subject: [PATCH 4/7] refactored and renamed file --- integration_test/httpresponse.go | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 integration_test/httpresponse.go diff --git a/integration_test/httpresponse.go b/integration_test/httpresponse.go deleted file mode 100644 index ee2fc59e..00000000 --- a/integration_test/httpresponse.go +++ /dev/null @@ -1,11 +0,0 @@ -package integrationtest - -type SuccessResponse struct { - Signature string `json:"signature"` -} - -type FailureResponse struct { - Id string `json:"id"` - Kind string `json:"kind"` - Msg string `json:"msg"` -} From 4dc7516b4210a638083e9f30b744a6cae0c9ea00 Mon Sep 17 00:00:00 2001 From: stephengaudet Date: Tue, 8 Aug 2023 17:13:38 -0700 Subject: [PATCH 5/7] GetPublicKey tests complete --- .github/workflows/build.yaml | 3 +++ integration_test/http.go | 16 +++++++++------- integration_test/vault_aws_test.go | 3 +++ integration_test/vault_az_test.go | 3 +++ integration_test/vault_gcp_test.go | 4 ++-- integration_test/vault_ledger_test.go | 2 +- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f939d61e..bf5ced03 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -125,6 +125,7 @@ jobs: VAULT_AWS_REGION: ${{ secrets.INTEGRATIONTEST_VAULT_AWS_REGION }} VAULT_AWS_PKH_TZ2: ${{ secrets.INTEGRATIONTEST_VAULT_AWS_TZ2 }} VAULT_AWS_PKH_TZ3: ${{ secrets.INTEGRATIONTEST_VAULT_AWS_TZ3 }} + VAULT_AWS_PKH_TZ3_PK: ${{ secrets.INTEGRATIONTEST_VAULT_AWS_TZ3_PK }} VAULT_AZ_CLIENTCERTTHUMB: ${{ secrets.INTEGRATIONTEST_VAULT_AZ_CLIENTCERTTHUMB }} VAULT_AZ_CLIENTID: ${{ secrets.INTEGRATIONTEST_VAULT_AZ_CLIENTID }} VAULT_AZ_RESGROUP: ${{ secrets.INTEGRATIONTEST_VAULT_AZ_RESGROUP }} @@ -134,6 +135,7 @@ jobs: VAULT_AZ_VAULT: ${{ secrets.INTEGRATIONTEST_VAULT_AZ_VAULT }} VAULT_AZ_TZ2: ${{ secrets.INTEGRATIONTEST_VAULT_AZ_TZ2 }} VAULT_AZ_TZ3: ${{ secrets.INTEGRATIONTEST_VAULT_AZ_TZ3 }} + VAULT_AZ_TZ3_PK: ${{ secrets.INTEGRATIONTEST_VAULT_AZ_TZ3_PK }} VAULT_GCP_PROJECTID: ${{ secrets.INTEGRATIONTEST_VAULT_GCP_PROJECTID }} VAULT_GCP_PRIVATEKEYID: ${{ secrets.INTEGRATIONTEST_VAULT_GCP_PRIVATEKEYID }} VAULT_GCP_PRIVATEKEY: ${{ secrets.INTEGRATIONTEST_VAULT_GCP_PRIVATEKEY }} @@ -143,6 +145,7 @@ jobs: VAULT_GCP_KEYRING: ${{ secrets.INTEGRATIONTEST_VAULT_GCP_KEYRING }} VAULT_GCP_LOCATION: ${{ secrets.INTEGRATIONTEST_VAULT_GCP_LOCATION }} VAULT_GCP_TZ3: ${{ secrets.INTEGRATIONTEST_VAULT_GCP_TZ3 }} + VAULT_GCP_TZ3_PK: ${{ secrets.INTEGRATIONTEST_VAULT_GCP_TZ3_PK }} run: > cd integration_test; export ARCH=amd64; diff --git a/integration_test/http.go b/integration_test/http.go index b6241fb1..973d53c1 100644 --- a/integration_test/http.go +++ b/integration_test/http.go @@ -3,12 +3,10 @@ package integrationtest import ( "bytes" "encoding/json" + "fmt" "io" "net/http" "strings" - "testing" - - "github.com/stretchr/testify/require" ) type SignSuccessResponse struct { @@ -64,12 +62,16 @@ func getPublicKey(pkh string) (int, []byte) { return resp.StatusCode, bytes } -func GetPublicKey(t *testing.T, pkh string, expect string) { +func GetPublicKey(pkh string) string { code, message := getPublicKey(pkh) - require.Equal(t, code, 200) + if code != 200 { + panic("GetPublicKey: http return code " + fmt.Sprint(code)) + } var r GetKeySuccessResponse dec := json.NewDecoder(bytes.NewReader(message)) err := dec.Decode(&r) - require.Nil(t, err) - require.Equal(t, expect, r.PublicKey) + if err != nil { + panic("GetPublicKey: error decoding json response: " + err.Error()) + } + return r.PublicKey } diff --git a/integration_test/vault_aws_test.go b/integration_test/vault_aws_test.go index fcf3c14f..32c43fdd 100644 --- a/integration_test/vault_aws_test.go +++ b/integration_test/vault_aws_test.go @@ -12,6 +12,7 @@ func TestAWSVault(t *testing.T) { tz2 := os.Getenv("VAULT_AWS_PKH_TZ2") tz3 := os.Getenv("VAULT_AWS_PKH_TZ3") + tz3pk := os.Getenv("VAULT_AWS_PKH_TZ3_PK") user := os.Getenv("VAULT_AWS_USER") key := os.Getenv("VAULT_AWS_KEY") secret := os.Getenv("VAULT_AWS_SECRET") @@ -64,4 +65,6 @@ func TestAWSVault(t *testing.T) { out, err = OctezClient("transfer", "1", "from", tz3alias, "to", "alice", "--burn-cap", "0.06425") assert.NoError(t, err) require.Contains(t, string(out), "Operation successfully injected in the node") + + require.Equal(t, tz3pk, GetPublicKey(tz3)) } diff --git a/integration_test/vault_az_test.go b/integration_test/vault_az_test.go index d377c9d9..a9a0a3ed 100644 --- a/integration_test/vault_az_test.go +++ b/integration_test/vault_az_test.go @@ -21,6 +21,7 @@ func TestAZVault(t *testing.T) { tz2 := os.Getenv("VAULT_AZ_TZ2") tz3 := os.Getenv("VAULT_AZ_TZ3") + tz3pk := os.Getenv("VAULT_AZ_TZ3_PK") tz2alias := "aztz2" tz3alias := "aztz3" @@ -67,4 +68,6 @@ func TestAZVault(t *testing.T) { out, err = OctezClient("transfer", "1", "from", tz3alias, "to", "alice", "--burn-cap", "0.06425") assert.NoError(t, err) require.Contains(t, string(out), "Operation successfully injected in the node") + + require.Equal(t, tz3pk, GetPublicKey(tz3)) } diff --git a/integration_test/vault_gcp_test.go b/integration_test/vault_gcp_test.go index e230c7bd..bcd21b6e 100644 --- a/integration_test/vault_gcp_test.go +++ b/integration_test/vault_gcp_test.go @@ -14,6 +14,7 @@ func TestGCPVault(t *testing.T) { location := os.Getenv("VAULT_GCP_LOCATION") keyring := os.Getenv("VAULT_GCP_KEYRING") tz3 := os.Getenv("VAULT_GCP_TZ3") + tz3pk := os.Getenv("VAULT_GCP_TZ3_PK") tz3alias := "gcptz3" //config @@ -46,6 +47,5 @@ func TestGCPVault(t *testing.T) { assert.NoError(t, err) require.Contains(t, string(out), "Operation successfully injected in the node") - //TODO: the PK belongs in the .env that is, another github secret in both actions and dependabot sections - GetPublicKey(t, tz3, "p2pk67dAL3pTy1vgBKzFHQNxV5cvzVR5ynnojBtPegAGAPhS59B2CSV") + require.Equal(t, tz3pk, GetPublicKey(tz3)) } diff --git a/integration_test/vault_ledger_test.go b/integration_test/vault_ledger_test.go index e5d84b0b..ffd84d69 100644 --- a/integration_test/vault_ledger_test.go +++ b/integration_test/vault_ledger_test.go @@ -20,5 +20,5 @@ func TestLedgerVault(t *testing.T) { } func TestLedgerVaultGetPublicKey(t *testing.T) { - GetPublicKey(t, "tz1RVYaHiobUKXMfJ47F7Rjxx5tu3LC35WSA", "edpktsKqhvR7kXbRWD7yDgLSD7PZUXvjLqf9SFscXhL52pUStF5nQp") + require.Equal(t, "edpktsKqhvR7kXbRWD7yDgLSD7PZUXvjLqf9SFscXhL52pUStF5nQp", GetPublicKey("tz1RVYaHiobUKXMfJ47F7Rjxx5tu3LC35WSA")) } From 12657874ea22643a4e75f71d7ec9343d85aea3a1 Mon Sep 17 00:00:00 2001 From: stephengaudet Date: Wed, 9 Aug 2023 16:12:36 -0700 Subject: [PATCH 6/7] tidy - consistent env var names --- .github/workflows/build.yaml | 6 +++--- integration_test/.env.vaults | 7 +++++-- integration_test/README.md | 2 ++ integration_test/vault_aws_test.go | 6 +++--- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index bf5ced03..6b6c12b6 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -123,9 +123,9 @@ jobs: VAULT_AWS_KEY: ${{ secrets.INTEGRATIONTEST_VAULT_AWS_KEY }} VAULT_AWS_SECRET: ${{ secrets.INTEGRATIONTEST_VAULT_AWS_SECRET }} VAULT_AWS_REGION: ${{ secrets.INTEGRATIONTEST_VAULT_AWS_REGION }} - VAULT_AWS_PKH_TZ2: ${{ secrets.INTEGRATIONTEST_VAULT_AWS_TZ2 }} - VAULT_AWS_PKH_TZ3: ${{ secrets.INTEGRATIONTEST_VAULT_AWS_TZ3 }} - VAULT_AWS_PKH_TZ3_PK: ${{ secrets.INTEGRATIONTEST_VAULT_AWS_TZ3_PK }} + VAULT_AWS_TZ2: ${{ secrets.INTEGRATIONTEST_VAULT_AWS_TZ2 }} + VAULT_AWS_TZ3: ${{ secrets.INTEGRATIONTEST_VAULT_AWS_TZ3 }} + VAULT_AWS_TZ3_PK: ${{ secrets.INTEGRATIONTEST_VAULT_AWS_TZ3_PK }} VAULT_AZ_CLIENTCERTTHUMB: ${{ secrets.INTEGRATIONTEST_VAULT_AZ_CLIENTCERTTHUMB }} VAULT_AZ_CLIENTID: ${{ secrets.INTEGRATIONTEST_VAULT_AZ_CLIENTID }} VAULT_AZ_RESGROUP: ${{ secrets.INTEGRATIONTEST_VAULT_AZ_RESGROUP }} diff --git a/integration_test/.env.vaults b/integration_test/.env.vaults index 850d6fa0..1ba5b8d0 100644 --- a/integration_test/.env.vaults +++ b/integration_test/.env.vaults @@ -2,8 +2,9 @@ export VAULT_AWS_USER=${{ secrets.INTEGRATIONTEST_VAULT_AWS_USER }} export VAULT_AWS_KEY=${{ secrets.INTEGRATIONTEST_VAULT_AWS_KEY }} export VAULT_AWS_SECRET=${{ secrets.INTEGRATIONTEST_VAULT_AWS_SECRET }} export VAULT_AWS_REGION=${{ secrets.INTEGRATIONTEST_VAULT_AWS_REGION }} -export VAULT_AWS_PKH_TZ2=${{ secrets.INTEGRATIONTEST_VAULT_AWS_TZ2 }} -export VAULT_AWS_PKH_TZ3=${{ secrets.INTEGRATIONTEST_VAULT_AWS_TZ3 }} +export VAULT_AWS_TZ2=${{ secrets.INTEGRATIONTEST_VAULT_AWS_TZ2 }} +export VAULT_AWS_TZ3=${{ secrets.INTEGRATIONTEST_VAULT_AWS_TZ3 }} +export VAULT_AWS_TZ3_PK=${{ secrets.INTEGRATIONTEST_VAULT_AWS_TZ3_PK }} export VAULT_AZ_CLIENTCERTTHUMB=${{ secrets.INTEGRATIONTEST_VAULT_AZ_CLIENTCERTTHUMB }} export VAULT_AZ_CLIENTID=${{ secrets.INTEGRATIONTEST_VAULT_AZ_CLIENTID }} @@ -14,6 +15,7 @@ export VAULT_AZ_TENANTID=${{ secrets.INTEGRATIONTEST_VAULT_AZ_TENANTID }} export VAULT_AZ_VAULT=${{ secrets.INTEGRATIONTEST_VAULT_AZ_VAULT }} export VAULT_AZ_TZ2=${{ secrets.INTEGRATIONTEST_VAULT_AZ_TZ2 }} export VAULT_AZ_TZ3=${{ secrets.INTEGRATIONTEST_VAULT_AZ_TZ3 }} +export VAULT_AZ_TZ3_PK=${{ secrets.INTEGRATIONTEST_VAULT_AZ_TZ3_PK }} export VAULT_GCP_PROJECTID=${{ secrets.INTEGRATIONTEST_VAULT_GCP_PROJECTID }} export VAULT_GCP_PRIVATEKEYID=${{ secrets.INTEGRATIONTEST_VAULT_GCP_PRIVATEKEYID }} @@ -24,3 +26,4 @@ export VAULT_GCP_X509_URL=${{ secrets.INTEGRATIONTEST_VAULT_GCP_X509_URL }} export VAULT_GCP_KEYRING=${{ secrets.INTEGRATIONTEST_VAULT_GCP_KEYRING }} export VAULT_GCP_LOCATION=${{ secrets.INTEGRATIONTEST_VAULT_GCP_LOCATION }} export VAULT_GCP_TZ3=${{ secrets.INTEGRATIONTEST_VAULT_GCP_TZ3 }} +export VAULT_GCP_TZ3_PK=${{ secrets.INTEGRATIONTEST_VAULT_GCP_TZ3_PK }} diff --git a/integration_test/README.md b/integration_test/README.md index ad335647..754337be 100644 --- a/integration_test/README.md +++ b/integration_test/README.md @@ -30,6 +30,8 @@ echo $PAT |docker login ghcr.io -u --password-stdin ## Running the tests +The tests are run in a [github workflow](/.github/workflows/build.yaml) and so the workflow should be consulted to learn how to run the tests locally. A more verbose explanation: + ```sh cd integration_test ``` diff --git a/integration_test/vault_aws_test.go b/integration_test/vault_aws_test.go index 32c43fdd..6187772c 100644 --- a/integration_test/vault_aws_test.go +++ b/integration_test/vault_aws_test.go @@ -10,9 +10,9 @@ import ( func TestAWSVault(t *testing.T) { - tz2 := os.Getenv("VAULT_AWS_PKH_TZ2") - tz3 := os.Getenv("VAULT_AWS_PKH_TZ3") - tz3pk := os.Getenv("VAULT_AWS_PKH_TZ3_PK") + tz2 := os.Getenv("VAULT_AWS_TZ2") + tz3 := os.Getenv("VAULT_AWS_TZ3") + tz3pk := os.Getenv("VAULT_AWS_TZ3_PK") user := os.Getenv("VAULT_AWS_USER") key := os.Getenv("VAULT_AWS_KEY") secret := os.Getenv("VAULT_AWS_SECRET") From d31e60aea9ccc6460007c50c55a18552637402a7 Mon Sep 17 00:00:00 2001 From: stephengaudet Date: Wed, 9 Aug 2023 16:13:38 -0700 Subject: [PATCH 7/7] add tz2 and tz4 integration tests --- .../.tezos-client/public_key_hashs | 4 ++- integration_test/.tezos-client/public_keys | 12 ++++++++- integration_test/.tezos-client/secret_keys | 6 ++++- integration_test/addresstypes_test.go | 26 +++++++++++++++++++ integration_test/cli_test.go | 3 +++ integration_test/flextesa.sh | 4 +++ integration_test/signatory-local-secret.json | 10 ++++++- integration_test/signatory.yaml | 15 +++++++++++ 8 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 integration_test/addresstypes_test.go diff --git a/integration_test/.tezos-client/public_key_hashs b/integration_test/.tezos-client/public_key_hashs index ff1e050f..f560d14b 100644 --- a/integration_test/.tezos-client/public_key_hashs +++ b/integration_test/.tezos-client/public_key_hashs @@ -2,4 +2,6 @@ { "name": "bob", "value": "tz1aSkwEot3L2kmUvcoxzjMomb9mvBNuzFK6" }, { "name": "opstest", "value": "tz1RKGhRF4TZNCXEfwyqZshGsVfrZeVU446B" }, { "name": "opstest1", "value": "tz1R8HJMzVdZ9RqLCknxeq9w5rSbiqJ41szi" }, - { "name": "speculos", "value": "tz1RVYaHiobUKXMfJ47F7Rjxx5tu3LC35WSA" } ] \ No newline at end of file + { "name": "speculos", "value": "tz1RVYaHiobUKXMfJ47F7Rjxx5tu3LC35WSA" }, + { "name": "tz2alias", "value": "tz2QPsZoZse4eeahhg5DdfnBDB4VbU1PwgxN" }, + { "name": "tz4alias", "value": "tz4XXtsYav3fZz2FSDa7hcx4F8sh8SaDWNME" } ] \ No newline at end of file diff --git a/integration_test/.tezos-client/public_keys b/integration_test/.tezos-client/public_keys index 750fbeee..9652cc44 100644 --- a/integration_test/.tezos-client/public_keys +++ b/integration_test/.tezos-client/public_keys @@ -22,4 +22,14 @@ "value": { "locator": "http://signatory:6732/tz1RVYaHiobUKXMfJ47F7Rjxx5tu3LC35WSA", - "key": "edpktsKqhvR7kXbRWD7yDgLSD7PZUXvjLqf9SFscXhL52pUStF5nQp" } } ] \ No newline at end of file + "key": "edpktsKqhvR7kXbRWD7yDgLSD7PZUXvjLqf9SFscXhL52pUStF5nQp" } }, + { "name": "tz2alias", + "value": + { "locator": + "http://signatory:6732/tz2QPsZoZse4eeahhg5DdfnBDB4VbU1PwgxN", + "key": "sppk7cvVVMRRtYTdriTB6KQqpXZt9TUwSTcpMWq4FwpvG2eVZ56UuHP" } }, + { "name": "tz4alias", + "value": + { "locator": + "http://signatory:6732/tz4XXtsYav3fZz2FSDa7hcx4F8sh8SaDWNME", + "key": "BLpk1nRV5SBB2QCxsiem5Neoywcizr3mkdp167HL1iKFgFvzPhKo4RSy7J8JBh2BgGgVYjNsRGwU" } } ] \ No newline at end of file diff --git a/integration_test/.tezos-client/secret_keys b/integration_test/.tezos-client/secret_keys index 96049b77..20c80b3d 100644 --- a/integration_test/.tezos-client/secret_keys +++ b/integration_test/.tezos-client/secret_keys @@ -7,4 +7,8 @@ { "name": "opstest1", "value": "http://signatory:6732/tz1R8HJMzVdZ9RqLCknxeq9w5rSbiqJ41szi" }, { "name": "speculos", - "value": "http://signatory:6732/tz1RVYaHiobUKXMfJ47F7Rjxx5tu3LC35WSA" } ] \ No newline at end of file + "value": "http://signatory:6732/tz1RVYaHiobUKXMfJ47F7Rjxx5tu3LC35WSA" }, + { "name": "tz2alias", + "value": "http://signatory:6732/tz2QPsZoZse4eeahhg5DdfnBDB4VbU1PwgxN" }, + { "name": "tz4alias", + "value": "http://signatory:6732/tz4XXtsYav3fZz2FSDa7hcx4F8sh8SaDWNME" } ] \ No newline at end of file diff --git a/integration_test/addresstypes_test.go b/integration_test/addresstypes_test.go new file mode 100644 index 00000000..d304e3d9 --- /dev/null +++ b/integration_test/addresstypes_test.go @@ -0,0 +1,26 @@ +package integrationtest + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +//there are enough existing integration tests using tz1 and tz3 addresses that it would be redundant to do so here + +func TestTz4(t *testing.T) { + //flextesa does not start when we try to use a tz4 bootstrap account, so, we have to fund it first + out, err := OctezClient("-w", "1", "transfer", "200", "from", "alice", "to", "tz4alias", "--burn-cap", "0.06425") + require.NoError(t, err) + require.Contains(t, string(out), "Operation successfully injected in the node") + + out, err = OctezClient("-w", "1", "transfer", "100", "from", "tz4alias", "to", "alice", "--burn-cap", "0.06425") + require.NoError(t, err) + require.Contains(t, string(out), "Operation successfully injected in the node") +} + +func TestTz2(t *testing.T) { + out, err := OctezClient("-w", "1", "transfer", "100", "from", "tz2alias", "to", "alice", "--burn-cap", "0.06425") + require.NoError(t, err) + require.Contains(t, string(out), "Operation successfully injected in the node") +} diff --git a/integration_test/cli_test.go b/integration_test/cli_test.go index 42c9dfa2..7d522d08 100644 --- a/integration_test/cli_test.go +++ b/integration_test/cli_test.go @@ -14,6 +14,9 @@ func TestCliList(t *testing.T) { out, err := SignatoryCli("list") assert.Nil(t, err) require.Contains(t, string(out), "tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb") + require.Contains(t, string(out), "tz2QPsZoZse4eeahhg5DdfnBDB4VbU1PwgxN") + require.Contains(t, string(out), "tz3Y2TkhTYG6MfPsijGfHFqBYrLCfwYb6HRB") + require.Contains(t, string(out), "tz4XXtsYav3fZz2FSDa7hcx4F8sh8SaDWNME") } func TestCliUsage(t *testing.T) { diff --git a/integration_test/flextesa.sh b/integration_test/flextesa.sh index ffaa0957..926a7320 100755 --- a/integration_test/flextesa.sh +++ b/integration_test/flextesa.sh @@ -7,6 +7,8 @@ export bob="$(flextesa key bob)" export speculos="speculos,edpktsKqhvR7kXbRWD7yDgLSD7PZUXvjLqf9SFscXhL52pUStF5nQp,tz1RVYaHiobUKXMfJ47F7Rjxx5tu3LC35WSA,unencrypted:edskRuZGqmXodGDghUhpHV5mfcmfEpA46FLs5kY6QBbyzpfb9JQEwpvrumBroTJ9iyHcY8PKdRAusCLPf7vDRVXhfN8WHE5r8m" export b0="$(flextesa key bootacc-0)" export user1="user1,edpkvNSVE2pL4eaCYrew1NEuLi4nnYmwQfe4tdM4NoVgNMEoVCNGoW,tz1QgHGuotVTCmYtA2Mr83FdiWLbwKqUvdnp,unencrypted:edsk3bNBh8s1eovydiRv6YitZHQpBkcS9s9ATQHRZfUQxUKcFU9Mh7" +export tz2alias="tz2alias,sppk7cvVVMRRtYTdriTB6KQqpXZt9TUwSTcpMWq4FwpvG2eVZ56UuHP,tz2QPsZoZse4eeahhg5DdfnBDB4VbU1PwgxN,unencrypted:spsk1XYsTqUsd7LaLs9a8qpmCvLVJeLEZEXkeAZS5dwcKgUZhv3cYw" +#export tz4alias="tz4alias,BLpk1nRV5SBB2QCxsiem5Neoywcizr3mkdp167HL1iKFgFvzPhKo4RSy7J8JBh2BgGgVYjNsRGwU,tz4XXtsYav3fZz2FSDa7hcx4F8sh8SaDWNME,unencrypted:BLsk1XMDG3iepYGj15mBWc7dYjrkpVVM4VH3y5DyBCN9iAGrELwRbY" root_path=/tmp/mini-box @@ -20,9 +22,11 @@ flextesa mini-net \ --add-bootstrap-account="$speculos@2_000_000_000_000" \ --add-bootstrap-account="$bob@2_000_000_000_000" \ --add-bootstrap-account="$user1@2_000_000_000_000" \ + --add-bootstrap-account="$tz2alias@2_000_000_000_000" \ --no-daemons-for=alice \ --no-daemons-for=bob \ --no-daemons-for=speculos \ --no-daemons-for=user1 \ + --no-daemons-for=tz2alias \ --until-level 200_000_000 \ --protocol-kind "$protocol" diff --git a/integration_test/signatory-local-secret.json b/integration_test/signatory-local-secret.json index 351b5aff..dd987781 100644 --- a/integration_test/signatory-local-secret.json +++ b/integration_test/signatory-local-secret.json @@ -18,5 +18,13 @@ { "name": "baker", "value": "unencrypted:edsk3REH79xaoCkNizrDo8cY4WYwEkrFLTAdjb1pjcP9yQora4qE3Y" - } + }, + { + "name": "tz2alias", + "value": "unencrypted:spsk1XYsTqUsd7LaLs9a8qpmCvLVJeLEZEXkeAZS5dwcKgUZhv3cYw" + }, + { + "name": "tz4alias", + "value": "unencrypted:BLsk1XMDG3iepYGj15mBWc7dYjrkpVVM4VH3y5DyBCN9iAGrELwRbY" + } ] diff --git a/integration_test/signatory.yaml b/integration_test/signatory.yaml index 44d47e67..00063e43 100644 --- a/integration_test/signatory.yaml +++ b/integration_test/signatory.yaml @@ -75,3 +75,18 @@ tezos: allow: generic: - transaction + + #tz2 + tz2QPsZoZse4eeahhg5DdfnBDB4VbU1PwgxN: + log_payloads: true + allow: + generic: + - transaction + + #tz4 + tz4XXtsYav3fZz2FSDa7hcx4F8sh8SaDWNME: + log_payloads: true + allow: + generic: + - transaction + - reveal