Skip to content

Commit

Permalink
Reentrancy Tests with Proxy (#310)
Browse files Browse the repository at this point in the history
## Type of change

<!--Delete points that do not apply-->

- New feature

## Changes

The following changes have been made:

- Adds tests to ensure that the reentrancy guard works with a proxy
contract
- Refactors the reentrancy guard test contracts to use storage

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
- [x] I have updated the changelog to reflect the changes on this PR.
  • Loading branch information
bitzoic authored Dec 10, 2024
1 parent 8e40e68 commit 0cec568
Show file tree
Hide file tree
Showing 14 changed files with 570 additions and 68 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Description of the upcoming release here.
### Added

- [#309](https://github.com/FuelLabs/sway-libs/pull/309) Adds fallback function test cases to the Reentrancy Guard Library.
- [#310](https://github.com/FuelLabs/sway-libs/pull/310) Adds proxy tests cases to the Reentrancy Guard Library.

### Changed

Expand Down
33 changes: 28 additions & 5 deletions tests/Forc.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "admin_test"
source = "member"
dependencies = [
"standards",
"standards git+https://github.com/FuelLabs/sway-standards?tag=v0.6.0#65e09f95ea8b9476b171a66c8a47108f352fa32c",
"std",
"sway_libs",
]
Expand Down Expand Up @@ -132,7 +132,7 @@ dependencies = [
name = "native_asset_lib"
source = "member"
dependencies = [
"standards",
"standards git+https://github.com/FuelLabs/sway-standards?tag=v0.6.0#65e09f95ea8b9476b171a66c8a47108f352fa32c",
"std",
"sway_libs",
]
Expand All @@ -141,7 +141,7 @@ dependencies = [
name = "ownership_test"
source = "member"
dependencies = [
"standards",
"standards git+https://github.com/FuelLabs/sway-standards?tag=v0.6.0#65e09f95ea8b9476b171a66c8a47108f352fa32c",
"std",
"sway_libs",
]
Expand Down Expand Up @@ -188,6 +188,24 @@ name = "reentrancy_fallback_abi"
source = "path+from-root-F53252C7DB7025EE"
dependencies = ["std"]

[[package]]
name = "reentrancy_proxy_abi"
source = "member"
dependencies = [
"standards git+https://github.com/FuelLabs/sway-standards?tag=v0.6.1#792639cdf391565e6e6a02482ea8a46d9604a6f5",
"std",
]

[[package]]
name = "reentrancy_proxy_contract"
source = "member"
dependencies = [
"reentrancy_proxy_abi",
"standards git+https://github.com/FuelLabs/sway-standards?tag=v0.6.1#792639cdf391565e6e6a02482ea8a46d9604a6f5",
"std",
"sway_libs",
]

[[package]]
name = "reentrancy_target_abi"
source = "member"
Expand Down Expand Up @@ -219,6 +237,11 @@ name = "standards"
source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.6.0#65e09f95ea8b9476b171a66c8a47108f352fa32c"
dependencies = ["std"]

[[package]]
name = "standards"
source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.6.1#792639cdf391565e6e6a02482ea8a46d9604a6f5"
dependencies = ["std"]

[[package]]
name = "std"
source = "git+https://github.com/fuellabs/sway?tag=v0.66.2#31486c0b47669612acb7c64d66ecb50aea281282"
Expand All @@ -228,15 +251,15 @@ dependencies = ["core"]
name = "sway_libs"
source = "path+from-root-8E8363697A2C7D80"
dependencies = [
"standards",
"standards git+https://github.com/FuelLabs/sway-standards?tag=v0.6.0#65e09f95ea8b9476b171a66c8a47108f352fa32c",
"std",
]

[[package]]
name = "upgradability_test"
source = "member"
dependencies = [
"standards",
"standards git+https://github.com/FuelLabs/sway-standards?tag=v0.6.0#65e09f95ea8b9476b171a66c8a47108f352fa32c",
"std",
"sway_libs",
]
2 changes: 2 additions & 0 deletions tests/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ members = [
"./src/reentrancy/reentrancy_attack_helper_contract",
"./src/reentrancy/reentrancy_target_abi",
"./src/reentrancy/reentrancy_target_contract",
"./src/reentrancy/reentrancy_proxy_abi",
"./src/reentrancy/reentrancy_proxy_contract",
"./src/signed_integers/signed_i8",
"./src/signed_integers/signed_i16",
"./src/signed_integers/signed_i32",
Expand Down
Loading

0 comments on commit 0cec568

Please sign in to comment.