Skip to content

Commit a9cc49b

Browse files
Merge branch 'master' into patch-10
2 parents 86aac64 + 59bce78 commit a9cc49b

File tree

15 files changed

+165
-15
lines changed

15 files changed

+165
-15
lines changed

src/dapp-tests/integration/tests.sh

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,52 @@ dapp_testnet() {
4949

5050
# dynamic fee transaction (EIP-1559)
5151
seth send "$A_ADDR" "on()" --gas 0xffff --password /dev/null --from "$ACC" --keystore "$TMPDIR"/8545/keystore --prio-fee 2gwei --gas-price 10gwei
52+
53+
# clean up
54+
killall geth
5255
}
5356

5457
dapp_testnet
5558

59+
# checks that seth send works with both checksummed and unchecksummed addresses
60+
seth_send_address_formats() {
61+
TMPDIR=$(mktemp -d)
62+
63+
dapp testnet --dir "$TMPDIR" &
64+
# give it a few secs to start up
65+
sleep 180
66+
read -r ACC BAL <<< "$(seth ls --keystore "$TMPDIR/8545/keystore")"
67+
68+
lower=$(echo "$ACC" | tr '[:upper:]' '[:lower:]')
69+
export ETH_GAS=0xffff
70+
71+
zero=0x0000000000000000000000000000000000000000
72+
73+
# with checksummed
74+
tx=$(seth send "$zero" --from "$ACC" --password /dev/null --value "$(seth --to-wei 1 ether)" --keystore "$TMPDIR"/8545/keystore --async)
75+
[[ $(seth tx "$tx" from) = "$lower" ]]
76+
77+
# without checksum
78+
tx=$(seth send "$zero" --from "$lower" --password /dev/null --value "$(seth --to-wei 1 ether)" --keystore "$TMPDIR"/8545/keystore --async)
79+
[[ $(seth tx "$tx" from) = "$lower" ]]
80+
81+
# try again with eth_rpc_accounts
82+
export ETH_RPC_ACCOUNTS=true
83+
84+
# with checksummed
85+
tx=$(seth send "$zero" --from "$ACC" --password /dev/null --value "$(seth --to-wei 1 ether)" --keystore "$TMPDIR"/8545/keystore --async)
86+
[[ $(seth tx "$tx" from) = "$lower" ]]
87+
88+
# without checksum
89+
tx=$(seth send "$zero" --from "$lower" --password /dev/null --value "$(seth --to-wei 1 ether)" --keystore "$TMPDIR"/8545/keystore --async)
90+
[[ $(seth tx "$tx" from) = "$lower" ]]
91+
92+
# clean up
93+
killall geth
94+
}
95+
96+
seth_send_address_formats
97+
5698
test_hevm_symbolic() {
5799
solc --bin-runtime -o . --overwrite factor.sol
58100
# should find counterexample
@@ -371,8 +413,52 @@ test-lookup-address2() {
371413
}
372414
test-lookup-address2
373415

416+
# SETH 4BYTE TESTS
417+
# seth 4byte
374418
test-4byte() {
375419
[[ $(seth 4byte a9059cbb | tail -n 1) = "transfer(address,uint256)" ]] || error
376420
}
377-
378421
test-4byte
422+
423+
# SETH FIXED POINT TESTS
424+
# seth --from-fix
425+
test-from-fix1() {
426+
[[ $(seth --from-fix 6 1) = 1000000 ]] || error
427+
}
428+
test-from-fix1
429+
430+
test-from-fix2() {
431+
[[ $(seth --from-fix 18 1) = 1000000000000000000 ]] || error
432+
}
433+
test-from-fix2
434+
435+
test-from-fix3() {
436+
[[ $(seth --from-fix 6 1.2345) = 1234500 ]] || error
437+
}
438+
test-from-fix3
439+
440+
test-from-fix4() {
441+
[[ $(seth --from-fix 18 1.23456789) = 1234567890000000000 ]] || error
442+
}
443+
test-from-fix4
444+
445+
# seth --to-fix
446+
test-to-fix1() {
447+
[[ $(seth --to-fix 6 1000000) = 1.000000 ]] || error
448+
}
449+
test-to-fix1
450+
451+
test-to-fix2() {
452+
[[ $(seth --to-fix 18 1000000000000000000) = 1.000000000000000000 ]] || error
453+
}
454+
test-to-fix2
455+
456+
test-to-fix3() {
457+
[[ $(seth --to-fix 6 1234500) = 1.234500 ]] || error
458+
}
459+
test-to-fix3
460+
461+
test-to-fix4() {
462+
[[ $(seth --to-fix 18 1234567890000000000) = 1.234567890000000000 ]] || error
463+
}
464+
test-to-fix4

src/dapp-tests/pass/abstract.sol

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pragma solidity ^0.6.7;
2+
3+
import {DSTest} from "ds-test/test.sol";
4+
5+
// should not be run (no code)
6+
abstract contract MyTest is DSTest {
7+
function testAbstract() public {
8+
assertTrue(true);
9+
}
10+
}
11+
12+
// should run and pass
13+
contract TestMy is MyTest {
14+
function testTrue() public {
15+
assertTrue(true);
16+
}
17+
}

src/dapp/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Dapp remappings ignores non-directories in `DAPP_LIB`
1313

14+
### Fixed
15+
16+
- Dapp can correctly parse replay strings from invariant tests
17+
1418
## [0.34.1] - 2021-09-08
1519

1620
### Added

src/dapp/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,8 @@ Spins up a geth testnet.
551551

552552
dapp-verify-contract -- verify contract source on etherscan
553553
Usage: dapp verify-contract <path>:<contractname> <address> [constructorArgs]
554+
555+
Example: `dapp verify-contract src/auth/authorities/RolesAuthority.sol:RolesAuthority 0x9ed0e..`
554556

555557
Requires `ETHERSCAN_API_KEY` to be set.
556558

src/dapp/libexec/dapp/dapp---hevm-opts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ opts=()
1616
[[ "$DAPP_TEST_CACHE" ]] && opts+=(--cache "$DAPP_TEST_CACHE")
1717
[[ "$DAPP_TEST_MATCH" ]] && opts+=(--match "$DAPP_TEST_MATCH")
1818
[[ "$DAPP_TEST_SOLVER" ]] && opts+=(--solver "$DAPP_TEST_SOLVER")
19-
[[ "$DAPP_TEST_REPLAY" ]] && opts+=(--replay \'"$DAPP_TEST_REPLAY"\')
19+
[[ "$DAPP_TEST_REPLAY" ]] && opts+=(--replay "$DAPP_TEST_REPLAY")
2020
[[ "$DAPP_TEST_VERBOSITY" ]] && opts+=(--verbose "$DAPP_TEST_VERBOSITY")
2121
[[ "$DAPP_TEST_COV_MATCH" ]] && opts+=(--cov-match "$DAPP_TEST_COV_MATCH")
2222
[[ "$DAPP_TEST_FUZZ_RUNS" ]] && opts+=(--fuzz-runs "$DAPP_TEST_FUZZ_RUNS")

src/hevm/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# hevm changelog
22

3+
## Unreleased
4+
5+
## Fixed
6+
7+
- Test contracts with no code (e.g. `abstract` contracts) are now skipped
8+
- Replay data for invariant tests is now displayed in a form that does not cause errors when used with `dapp test --replay`
9+
310
## [0.48.1] - 2021-09-08
411

512
### Added

src/hevm/src/EVM/Dapp.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ findUnitTests match =
140140
Nothing -> []
141141
Just _ ->
142142
let testNames = unitTestMethodsFiltered (regexMatches match) c
143-
in [(view contractName c, testNames) | not (null testNames)]
143+
in [(view contractName c, testNames) | not (BS.null (view runtimeCode c)) && not (null testNames)]
144144

145145
unitTestMethodsFiltered :: (Text -> Bool) -> (SolcContract -> [(Test, [AbiType])])
146146
unitTestMethodsFiltered matcher c =

src/hevm/src/EVM/UnitTest.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ exploreRun opts@UnitTestOptions{..} initialVm testName replayTxs = do
581581
then return ("\x1b[32m[PASS]\x1b[0m " <> testName <> " (runs: " <> (pack $ show fuzzRuns) <>", depth: " <> pack (show depth) <> ")",
582582
Right (passOutput vm' opts testName), vm') -- no canonical "post vm"
583583
else let replayText = if null replayTxs
584-
then "\nReplay data: '(" <> pack (show testName) <> ", " <> pack (show (show (ByteStringS $ rlpencode counterex))) <> ")'"
584+
then "\nReplay data: '(" <> pack (show testName) <> "," <> pack (show (show (ByteStringS $ rlpencode counterex))) <> ")'"
585585
else " (replayed)"
586586
in return ("\x1b[31m[FAIL]\x1b[0m " <> testName <> replayText, Left (failOutput vm' opts testName), vm')
587587

src/seth/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
### Changed
1010

11-
- `seth --to-wei` now uses eth instead of wei as the default unit for conversions
1211
- `seth 4byte` command returns the response from querying [4byte.directory](https://www.4byte.directory/) for a given function signature
1312
- `seth 4byte-decode` command queries 4byte.directory for matching function signatures, uses one to decode the calldata, and prints the decoded calldata
1413
- `seth 4byte-event` command returns the response from querying 4byte.directory for a given event topic
1514
- `seth abi-encode` command returns the ABI encoded values without the function signature
1615
- `seth index` command returns the slot number for the specified mapping type and input data
16+
- `seth --from-fix` command converts fixed point numbers into parsed integers with the specified number of decimals
17+
18+
### Fixed
19+
20+
- Address lookup no longer fails if `ETH_RPC_ACCOUNTS` is set, and `ETH_FROM` is an unchecksummed address
1721

1822
## [0.11.0] - 2021-09-08
1923

src/seth/README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ hardware wallets—even if you use a remote RPC node like Infura's.
5757
- [`seth --calldata-decode`]
5858
- [`seth --from-ascii`]
5959
- [`seth --from-bin`]
60+
- [`seth --from-fix`]
6061
- [`seth --from-wei`]
6162
- [`seth --max-int`]
6263
- [`seth --max-uint`]
@@ -65,6 +66,7 @@ hardware wallets—even if you use a remote RPC node like Infura's.
6566
- [`seth --to-ascii`]
6667
- [`seth --to-bytes32`]
6768
- [`seth --to-dec`]
69+
- [`seth --to-fix`]
6870
- [`seth --to-hex`]
6971
- [`seth --to-int256`]
7072
- [`seth --to-uint256`]
@@ -374,6 +376,14 @@ Convert binary data into hex data.
374376

375377
Reads binary data from standard input and prints it as hex data.
376378

379+
### `seth --from-fix`
380+
381+
Convert fixed point numbers into parsed integers with the specified number of decimals.
382+
383+
seth --from-fix <decimals> <value>
384+
385+
For example, use `seth --to-fix 6 1` to convert 1 USDC into the parsed quantity of 1,000,000 USDC
386+
377387
### `seth --from-wei`
378388

379389
Convert a wei amount into another unit (ETH by default).
@@ -430,6 +440,14 @@ Convert a hex value with 0x prefix into a decimal number.
430440

431441
seth --to-dec <hexvalue>
432442

443+
### `seth --to-fix`
444+
445+
Convert parsed integers into fixed point with the specified number of decimals.
446+
447+
seth --to-fix <decimals> <value>
448+
449+
For example, use `seth --to-fix 6 1000000` to convert the parsed amount of 1,000,000 USDC into a formatted amount of 1 USDC.
450+
433451
### `seth --to-hex`
434452

435453
Convert a decimal number into a hex value.
@@ -708,8 +726,8 @@ ABI specification.
708726

709727
### `seth lookup-address`
710728

711-
Print the address the provided ENS name resolves to. If the name is not
712-
owned or does not have a resolver configured, an `invalid data for
729+
Print the ENS name the provided address reverse resolves to. If the name is
730+
not owned or does not have a resolver configured, an `invalid data for
713731
function output` error will be thrown. An error will also be thrown
714732
if the forward and reverse resolution do not match.
715733

@@ -865,7 +883,9 @@ Show all fields unless `<field>` is given.
865883
[`seth --abi-decode`]: #seth---abi-decode
866884
[`seth --from-ascii`]: #seth---from-ascii
867885
[`seth --from-bin`]: #seth---from-bin
886+
[`seth --from-fix`]: #seth---from-fix
868887
[`seth --from-wei`]: #seth---from-wei
888+
[`seth --to-fix`]: #seth---to-fix
869889
[`seth --to-wei`]: #seth---to-wei
870890
[`seth --to-int256`]: #seth---to-int256
871891
[`seth --to-uint256`]: #seth---to-uint256

0 commit comments

Comments
 (0)