From f5413e771496106ef48786a9b8416972311594b7 Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Mon, 11 Sep 2023 16:21:20 -0400 Subject: [PATCH] fix: add test to see if contract can be deployed after hash has expired --- cmd/soroban-rpc/internal/test/cli_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmd/soroban-rpc/internal/test/cli_test.go b/cmd/soroban-rpc/internal/test/cli_test.go index 7da7fe808a..70d4ade6bf 100644 --- a/cmd/soroban-rpc/internal/test/cli_test.go +++ b/cmd/soroban-rpc/internal/test/cli_test.go @@ -7,6 +7,7 @@ import ( "os" "strings" "testing" + "time" "github.com/creachadair/jrpc2" "github.com/creachadair/jrpc2/jhttp" @@ -38,6 +39,18 @@ func TestCLIContractInstallAndDeploy(t *testing.T) { isValidContractID(t, last) } +func TestCLIContractInstallAndDeployAfterExpiration(t *testing.T) { + NewCLITest(t) + runSuccessfulCLICmd(t, "contract install --wasm "+helloWorldContractPath) + time.Sleep(time.Second * 20) + wasm := getHelloWorldContract(t) + contractHash := xdr.Hash(sha256.Sum256(wasm)) + output := runSuccessfulCLICmd(t, fmt.Sprintf("contract deploy --salt 0 --wasm-hash %s", contractHash.HexString())) + lines := filterSlice(strings.Split(output, "\n"), nonEmpty) + last := lines[len(lines)-1] + isValidContractID(t, last) +} + func nonEmpty(s string) bool { return s != "" }