Skip to content

Commit

Permalink
Test case added
Browse files Browse the repository at this point in the history
  • Loading branch information
priyankabose committed Jan 29, 2025
1 parent 95c223a commit e7a7da5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions fuzzing/fuzzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ func TestCheatCodes(t *testing.T) {
"testdata/contracts/cheat_codes/vm/roll.sol",
"testdata/contracts/cheat_codes/vm/store_load.sol",
"testdata/contracts/cheat_codes/vm/warp.sol",
"testdata/contracts/cheat_codes/vm/label.sol",
}

// FFI test will fail on Windows because "echo" is a shell command, not a system command, so we diverge these
Expand Down
25 changes: 25 additions & 0 deletions fuzzing/testdata/contracts/cheat_codes/vm/label.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// This test ensures that label can be set for an address
interface CheatCodes {
function label(address, string memory) external;
}

contract LabelContract {
function testLabel() public {
assert(false);
}
}

contract TestContract {

function test() public {
// Obtain our cheat code contract reference.
CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);

// Create a contract
LabelContract alice = new LabelContract();

// set label and verify.
cheats.label(address(alice), "Alice");
alice.testLabel();
}
}
5 changes: 2 additions & 3 deletions utils/address_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package utils

import (
"encoding/hex"
"fmt"
"regexp"
"strings"

Expand Down Expand Up @@ -72,11 +71,11 @@ func ResolveAddressToLabelFromString(str string, addressToLabel map[common.Addre
processedString := addressRegex.ReplaceAllStringFunc(str, func(match string) string {
address := common.HexToAddress(match) // Convert the match to an Ethereum address
if label, exists := addressToLabel[address]; exists {
fmt.Printf("Replacing address %s with label %s in element: %s\n", match, label, str)
//fmt.Printf("Replacing address %s with label: %s\n", match, label)
return label // Replace address with label
}
trimmedAddress := TrimLeadingZeroesFromAddress(match)
fmt.Printf("Address %s does not have a label, trimming leading zeroes to: %s\n", match, trimmedAddress)
//fmt.Printf("Address %s does not have a label, trimming leading zeroes to: %s\n", match, trimmedAddress)
return trimmedAddress // Keep the address unchanged if no label is found
})

Expand Down

0 comments on commit e7a7da5

Please sign in to comment.