-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6829c4
commit 14fd8f8
Showing
8 changed files
with
87 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
cast_output=$(cast call 0x9fb0F63B569f9FD8718Bbb2856a4b6F2458C2d70 "upload_to_arweave(string)" "hello world!" --rpc-url https://testnet-rpc.wvm.dev) | ||
|
||
data_hex=$(echo "$cast_output" | cut -c 129-214) | ||
|
||
# Decode the hex data to get the Arweave transaction hash | ||
tx_hash=$(echo "$data_hex" | xxd -r -p) | ||
|
||
# Generate the viewblock.io URL using the extracted transaction hash | ||
viewblock_url="https://viewblock.io/arweave/tx/$tx_hash" | ||
|
||
# Output the URL | ||
echo "$viewblock_url" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import "forge-std/Test.sol"; | ||
import "../src/MergedPrecompiles0x69420.sol"; | ||
|
||
contract MergedPrecompiles0x69420Test is Test { | ||
MergedPrecompiles0x69420 public precompile; | ||
|
||
// Events we want to test | ||
event UploadAttempted(string data, bool success); | ||
event UploadError(string reason); | ||
event ReadAttempted(string txId, bool success); | ||
event ReadError(string reason); | ||
|
||
function setUp() public { | ||
precompile = new MergedPrecompiles0x69420(); | ||
} | ||
|
||
function testReadFromArweave() public { | ||
// Mock the precompile call | ||
vm.mockCall( | ||
address(0x18), | ||
abi.encodePacked("test_tx_id"), | ||
abi.encodePacked("mocked_result") | ||
); | ||
|
||
bytes memory result = precompile.read_from_arweave("test_tx_id"); | ||
assertEq(result, "mocked_result"); | ||
} | ||
|
||
function testReadFromArweaveFailure() public { | ||
// Mock a failed precompile call | ||
vm.mockCallRevert( | ||
address(0x18), | ||
abi.encodePacked("invalid_tx_id"), | ||
"Read operation failed" | ||
); | ||
|
||
vm.expectRevert("ArweaveReader: read operation failed"); | ||
precompile.read_from_arweave("invalid_tx_id"); | ||
} | ||
|
||
function testUploadToArweave() public { | ||
// Mock successful upload | ||
vm.mockCall( | ||
address(0x17), | ||
abi.encodePacked("test_data"), | ||
abi.encodePacked("mocked_tx_id") | ||
); | ||
|
||
// Expect the UploadAttempted event to be emitted | ||
vm.expectEmit(true, true, true, true); | ||
emit UploadAttempted("test_data", true); | ||
|
||
bytes memory result = precompile.upload_to_arweave("test_data"); | ||
assertEq(result, "mocked_tx_id"); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.