diff --git a/scripts/chain-initiator/retrieve-snapshot.go b/scripts/chain-initiator/retrieve-snapshot.go index f72833ff08..5bfc5c9059 100644 --- a/scripts/chain-initiator/retrieve-snapshot.go +++ b/scripts/chain-initiator/retrieve-snapshot.go @@ -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) diff --git a/test/integration/framework/src/siftool/eth.py b/test/integration/framework/src/siftool/eth.py index 761283cc11..5464c2e98d 100644 --- a/test/integration/framework/src/siftool/eth.py +++ b/test/integration/framework/src/siftool/eth.py @@ -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: