Skip to content

Commit

Permalink
test: fix integration test 1
Browse files Browse the repository at this point in the history
  • Loading branch information
snobbee committed Jun 14, 2024
1 parent 602934a commit 2173143
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
31 changes: 29 additions & 2 deletions scripts/chain-initiator/retrieve-snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,38 @@ package main
import (
"log"
"os/exec"
"strings"
)

func retrieveSnapshot(snapshotUrl, homePath string) {
// Construct the command string
cmdString := "curl -o - -L " + snapshotUrl + " | lz4 -c -d - | tar -x -C " + homePath
var cmdString string
isUrl := strings.HasPrefix(snapshotUrl, "http://") || strings.HasPrefix(snapshotUrl, "https://")

// Check the file type and construct the command accordingly
if strings.HasSuffix(snapshotUrl, ".tar.lz4") {
if isUrl {
cmdString = "curl -o - -L " + snapshotUrl + " | lz4 -c -d - | tar -x -C " + homePath
} else {
cmdString = "lz4 -c -d " + snapshotUrl + " | tar -x -C " + homePath
}
} else if strings.HasSuffix(snapshotUrl, ".tar.gz") {
if isUrl {
cmdString = "curl -o - -L " + snapshotUrl + " | tar -xz -C " + homePath
} else {
cmdString = "tar -xz -f " + snapshotUrl + " -C " + homePath
}
} else if strings.HasSuffix(snapshotUrl, ".tar") {
if isUrl {
cmdString = "curl -o - -L " + snapshotUrl + " | tar -x -C " + homePath
} else {
cmdString = "tar -x -f " + snapshotUrl + " -C " + homePath
}
} else {
log.Fatalf(Red+"Invalid snapshot url or path: %s", snapshotUrl)
}

// Print cmdString
log.Printf(Green+"Retrieving snapshot using command: %s", cmdString)

// Execute the command using /bin/sh
cmd := exec.Command("/bin/sh", "-c", cmdString)
Expand Down
2 changes: 1 addition & 1 deletion test/integration/framework/src/siftool/eth.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def set_private_key(self, addr: Address, private_key: PrivateKey):
if private_key is None:
self.private_keys.pop(addr) # Remove
else:
assert re.match("^([0-9a-f]{64})$", private_key)
assert re.match("^([0-9a-f]{62}|[0-9a-f]{64})$", private_key), "Private key must be 62 or 64 hexadecimal characters long"
assert addr == a.from_key(private_key).address, f"Private key does not correspond to given address {addr}"
self.private_keys[addr] = private_key
if self.is_local_node:
Expand Down

0 comments on commit 2173143

Please sign in to comment.