Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
055737a2
Unverified
Commit
055737a2
authored
Jul 19, 2021
by
Kelvin Fichter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix[smock]: add naive support for packed storage slots
parent
8e99c149
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
3 deletions
+21
-3
storage.ts
packages/smock/src/smoddit/storage.ts
+5
-1
SimpleStorageGetter.sol
packages/smock/test/contracts/SimpleStorageGetter.sol
+5
-0
smoddit.spec.ts
packages/smock/test/smoddit/smoddit.spec.ts
+11
-2
No files found.
packages/smock/src/smoddit/storage.ts
View file @
055737a2
...
@@ -98,10 +98,14 @@ export const getStorageSlots = (
...
@@ -98,10 +98,14 @@ export const getStorageSlots = (
ethers
.
BigNumber
.
from
(
slotHash
).
add
(
inputSlot
.
slot
)
ethers
.
BigNumber
.
from
(
slotHash
).
add
(
inputSlot
.
slot
)
)
)
const
slotValue
=
toHexString32
(
`0x`
+
toHexString32
(
flat
[
key
]).
slice
(
2
+
variableDef
.
offset
*
2
)
)
slots
.
push
({
slots
.
push
({
label
:
key
,
label
:
key
,
hash
:
slotHash
,
hash
:
slotHash
,
value
:
toHexString32
(
flat
[
key
])
,
value
:
slotValue
,
})
})
}
}
...
...
packages/smock/test/contracts/SimpleStorageGetter.sol
View file @
055737a2
...
@@ -23,6 +23,11 @@ contract SimpleStorageGetter {
...
@@ -23,6 +23,11 @@ contract SimpleStorageGetter {
bool internal _packedA;
bool internal _packedA;
address internal _packedB;
address internal _packedB;
// Regression for #1275.
uint256 internal __packingSpacerUnused1; // Spacer to avoid packing with the above two.
bool public booleanOne = true;
bool public booleanTwo = true;
constructor(
constructor(
uint256 _inA
uint256 _inA
) {
) {
...
...
packages/smock/test/smoddit/smoddit.spec.ts
View file @
055737a2
...
@@ -53,8 +53,7 @@ describe('smoddit', () => {
...
@@ -53,8 +53,7 @@ describe('smoddit', () => {
expect
(
await
smod
.
getAddress
()).
to
.
equal
(
ret
)
expect
(
await
smod
.
getAddress
()).
to
.
equal
(
ret
)
})
})
// TODO: Need to solve this with a rewrite.
it
(
'
should be able to return an address in a packed storage slot
'
,
async
()
=>
{
it
.
skip
(
'
should be able to return an address in a packed storage slot
'
,
async
()
=>
{
const
ret
=
'
0x558ba9b8d78713fbf768c1f8a584485B4003f43F
'
const
ret
=
'
0x558ba9b8d78713fbf768c1f8a584485B4003f43F
'
await
smod
.
smodify
.
put
({
await
smod
.
smodify
.
put
({
...
@@ -170,6 +169,16 @@ describe('smoddit', () => {
...
@@ -170,6 +169,16 @@ describe('smoddit', () => {
expect
(
await
smod
.
getAddressToAddressMapValue
(
key
)).
to
.
equal
(
val
)
expect
(
await
smod
.
getAddressToAddressMapValue
(
key
)).
to
.
equal
(
val
)
})
})
it
(
'
should be able to pack two booleans
'
,
async
()
=>
{
const
ret
=
true
expect
(
await
smod
.
booleanTwo
()).
to
.
equal
(
ret
)
await
smod
.
smodify
.
put
({
booleanTwo
:
ret
,
})
expect
(
await
smod
.
booleanTwo
()).
to
.
equal
(
ret
)
})
})
})
})
})
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment