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
ae9f35d9
Unverified
Commit
ae9f35d9
authored
Jan 31, 2023
by
mergify[bot]
Committed by
GitHub
Jan 31, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4812 from ethereum-optimism/fix/delete-hh-drippie-tests
ctp: delete hardhat drippie tests
parents
8a763995
a635f191
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
292 deletions
+0
-292
Drippie.spec.ts
...eriphery/test/contracts/universal/drippie/Drippie.spec.ts
+0
-292
No files found.
packages/contracts-periphery/test/contracts/universal/drippie/Drippie.spec.ts
deleted
100644 → 0
View file @
8a763995
import
hre
from
'
hardhat
'
import
{
SignerWithAddress
}
from
'
@nomiclabs/hardhat-ethers/signers
'
import
{
Contract
}
from
'
ethers
'
import
{
toRpcHexString
}
from
'
@eth-optimism/core-utils
'
import
{
expect
}
from
'
../../../setup
'
import
{
deploy
}
from
'
../../../helpers
'
describe
(
'
Drippie
'
,
()
=>
{
const
DEFAULT_DRIP_NAME
=
'
drippity drip drip
'
const
DEFAULT_DRIP_CONFIG
=
{
interval
:
hre
.
ethers
.
BigNumber
.
from
(
100
),
dripcheck
:
''
,
// Gets added in setup
checkparams
:
'
0x
'
,
actions
:
[
{
target
:
'
0x
'
+
'
11
'
.
repeat
(
20
),
data
:
'
0x
'
,
value
:
hre
.
ethers
.
BigNumber
.
from
(
1
),
},
],
}
let
signer1
:
SignerWithAddress
let
signer2
:
SignerWithAddress
before
(
'
signer setup
'
,
async
()
=>
{
;[
signer1
,
signer2
]
=
await
hre
.
ethers
.
getSigners
()
})
before
(
'
deploy default dripcheck
'
,
async
()
=>
{
DEFAULT_DRIP_CONFIG
.
dripcheck
=
(
await
deploy
(
'
CheckTrue
'
)).
address
})
let
SimpleStorage
:
Contract
let
Drippie
:
Contract
beforeEach
(
'
deploy contracts
'
,
async
()
=>
{
SimpleStorage
=
await
deploy
(
'
SimpleStorage
'
)
Drippie
=
await
deploy
(
'
Drippie
'
,
{
signer
:
signer1
,
args
:
[
signer1
.
address
],
})
})
beforeEach
(
'
balance setup
'
,
async
()
=>
{
await
hre
.
ethers
.
provider
.
send
(
'
hardhat_setBalance
'
,
[
Drippie
.
address
,
toRpcHexString
(
DEFAULT_DRIP_CONFIG
.
actions
[
0
].
value
.
mul
(
100000
)),
])
await
hre
.
ethers
.
provider
.
send
(
'
hardhat_setBalance
'
,
[
DEFAULT_DRIP_CONFIG
.
actions
[
0
].
target
,
'
0x0
'
,
])
})
describe
(
'
create
'
,
()
=>
{
describe
(
'
when called by authorized address
'
,
()
=>
{
it
(
'
should create a drip with the given name
'
,
async
()
=>
{
await
expect
(
Drippie
.
create
(
DEFAULT_DRIP_NAME
,
DEFAULT_DRIP_CONFIG
)
).
to
.
emit
(
Drippie
,
'
DripCreated
'
)
const
drip
=
await
Drippie
.
drips
(
DEFAULT_DRIP_NAME
)
expect
(
drip
.
status
).
to
.
equal
(
1
)
// PAUSED
expect
(
drip
.
last
).
to
.
deep
.
equal
(
hre
.
ethers
.
BigNumber
.
from
(
0
))
expect
(
drip
.
config
.
interval
).
to
.
deep
.
equal
(
DEFAULT_DRIP_CONFIG
.
interval
)
expect
(
drip
.
config
.
dripcheck
).
to
.
deep
.
equal
(
DEFAULT_DRIP_CONFIG
.
dripcheck
)
expect
(
drip
.
config
.
checkparams
).
to
.
deep
.
equal
(
DEFAULT_DRIP_CONFIG
.
checkparams
)
expect
(
drip
.
config
.
actions
[
0
][
0
]).
to
.
deep
.
equal
(
DEFAULT_DRIP_CONFIG
.
actions
[
0
].
target
)
expect
(
drip
.
config
.
actions
[
0
][
1
]).
to
.
deep
.
equal
(
DEFAULT_DRIP_CONFIG
.
actions
[
0
].
data
)
expect
(
drip
.
config
.
actions
[
0
][
2
]).
to
.
deep
.
equal
(
DEFAULT_DRIP_CONFIG
.
actions
[
0
].
value
)
})
it
(
'
should not be able to create the same drip twice
'
,
async
()
=>
{
await
Drippie
.
create
(
DEFAULT_DRIP_NAME
,
DEFAULT_DRIP_CONFIG
)
await
expect
(
Drippie
.
create
(
DEFAULT_DRIP_NAME
,
DEFAULT_DRIP_CONFIG
)
).
to
.
be
.
revertedWith
(
'
Drippie: drip with that name already exists
'
)
})
})
describe
(
'
when called by not authorized address
'
,
()
=>
{
it
(
'
should revert
'
,
async
()
=>
{
await
expect
(
Drippie
.
connect
(
signer2
).
create
(
DEFAULT_DRIP_NAME
,
DEFAULT_DRIP_CONFIG
)
).
to
.
be
.
revertedWith
(
'
UNAUTHORIZED
'
)
})
})
})
describe
(
'
status
'
,
()
=>
{
describe
(
'
when called by authorized address
'
,
()
=>
{
it
(
'
should allow setting between PAUSED and ACTIVE
'
,
async
()
=>
{
await
Drippie
.
create
(
DEFAULT_DRIP_NAME
,
DEFAULT_DRIP_CONFIG
)
expect
((
await
Drippie
.
drips
(
DEFAULT_DRIP_NAME
)).
status
).
to
.
equal
(
1
)
// PAUSED
await
Drippie
.
status
(
DEFAULT_DRIP_NAME
,
2
)
// ACTIVE
expect
((
await
Drippie
.
drips
(
DEFAULT_DRIP_NAME
)).
status
).
to
.
equal
(
2
)
// ACTIVE
await
Drippie
.
status
(
DEFAULT_DRIP_NAME
,
1
)
// PAUSED
expect
((
await
Drippie
.
drips
(
DEFAULT_DRIP_NAME
)).
status
).
to
.
equal
(
1
)
// PAUSED
})
it
(
'
should not allow setting status to NONE
'
,
async
()
=>
{
await
Drippie
.
create
(
DEFAULT_DRIP_NAME
,
DEFAULT_DRIP_CONFIG
)
await
expect
(
Drippie
.
status
(
DEFAULT_DRIP_NAME
,
0
)).
to
.
be
.
revertedWith
(
'
Drippie: drip status can never be set back to NONE after creation
'
)
})
it
(
'
should not allow setting status to same status as before
'
,
async
()
=>
{
await
Drippie
.
create
(
DEFAULT_DRIP_NAME
,
DEFAULT_DRIP_CONFIG
)
await
expect
(
Drippie
.
status
(
DEFAULT_DRIP_NAME
,
1
)).
to
.
be
.
revertedWith
(
'
Drippie: cannot set drip status to the same status as its current status
'
)
})
it
(
'
should allow setting status to ARCHIVED if PAUSED
'
,
async
()
=>
{
await
Drippie
.
create
(
DEFAULT_DRIP_NAME
,
DEFAULT_DRIP_CONFIG
)
await
Drippie
.
status
(
DEFAULT_DRIP_NAME
,
3
)
// ARCHIVED
expect
((
await
Drippie
.
drips
(
DEFAULT_DRIP_NAME
)).
status
).
to
.
equal
(
3
)
// ARCHIVED
})
it
(
'
should not allow setting status to ARCHIVED if ACTIVE
'
,
async
()
=>
{
await
Drippie
.
create
(
DEFAULT_DRIP_NAME
,
DEFAULT_DRIP_CONFIG
)
await
Drippie
.
status
(
DEFAULT_DRIP_NAME
,
2
)
// ACTIVE
await
expect
(
Drippie
.
status
(
DEFAULT_DRIP_NAME
,
3
)).
to
.
be
.
revertedWith
(
'
Drippie: drip must first be paused before being archived
'
)
})
it
(
'
should not allow setting status to PAUSED if ARCHIVED
'
,
async
()
=>
{
await
Drippie
.
create
(
DEFAULT_DRIP_NAME
,
DEFAULT_DRIP_CONFIG
)
await
Drippie
.
status
(
DEFAULT_DRIP_NAME
,
3
)
// ARCHIVED
await
expect
(
Drippie
.
status
(
DEFAULT_DRIP_NAME
,
2
)).
to
.
be
.
revertedWith
(
'
Drippie: drip with that name has been archived
'
)
})
it
(
'
should not allow setting status to ACTIVE if ARCHIVED
'
,
async
()
=>
{
await
Drippie
.
create
(
DEFAULT_DRIP_NAME
,
DEFAULT_DRIP_CONFIG
)
await
Drippie
.
status
(
DEFAULT_DRIP_NAME
,
3
)
// ARCHIVED
await
expect
(
Drippie
.
status
(
DEFAULT_DRIP_NAME
,
1
)).
to
.
be
.
revertedWith
(
'
Drippie: drip with that name has been archived
'
)
})
it
(
'
should revert if the drip does not exist yet
'
,
async
()
=>
{
await
expect
(
Drippie
.
status
(
DEFAULT_DRIP_NAME
,
1
)).
to
.
be
.
revertedWith
(
'
Drippie: drip with that name does not exist
'
)
})
})
describe
(
'
when called by not authorized address
'
,
()
=>
{
it
(
'
should revert
'
,
async
()
=>
{
await
expect
(
Drippie
.
connect
(
signer2
).
status
(
DEFAULT_DRIP_NAME
,
1
)
).
to
.
be
.
revertedWith
(
'
UNAUTHORIZED
'
)
})
})
})
describe
(
'
drip
'
,
()
=>
{
it
(
'
should drip the amount
'
,
async
()
=>
{
await
Drippie
.
create
(
DEFAULT_DRIP_NAME
,
DEFAULT_DRIP_CONFIG
)
await
Drippie
.
status
(
DEFAULT_DRIP_NAME
,
2
)
// ACTIVE
await
expect
(
Drippie
.
drip
(
DEFAULT_DRIP_NAME
)).
to
.
emit
(
Drippie
,
'
DripExecuted
'
)
expect
(
await
signer1
.
provider
.
getBalance
(
DEFAULT_DRIP_CONFIG
.
actions
[
0
].
target
)
).
to
.
equal
(
DEFAULT_DRIP_CONFIG
.
actions
[
0
].
value
)
})
it
(
'
should be able to trigger one function
'
,
async
()
=>
{
await
Drippie
.
create
(
DEFAULT_DRIP_NAME
,
{
...
DEFAULT_DRIP_CONFIG
,
actions
:
[
{
target
:
SimpleStorage
.
address
,
data
:
SimpleStorage
.
interface
.
encodeFunctionData
(
'
set
'
,
[
'
0x
'
+
'
33
'
.
repeat
(
32
),
'
0x
'
+
'
44
'
.
repeat
(
32
),
]),
value
:
hre
.
ethers
.
BigNumber
.
from
(
0
),
},
],
})
await
Drippie
.
status
(
DEFAULT_DRIP_NAME
,
2
)
// ACTIVE
await
Drippie
.
drip
(
DEFAULT_DRIP_NAME
)
expect
(
await
SimpleStorage
.
get
(
'
0x
'
+
'
33
'
.
repeat
(
32
))).
to
.
equal
(
'
0x
'
+
'
44
'
.
repeat
(
32
)
)
})
it
(
'
should be able to trigger two functions
'
,
async
()
=>
{
await
Drippie
.
create
(
DEFAULT_DRIP_NAME
,
{
...
DEFAULT_DRIP_CONFIG
,
actions
:
[
{
target
:
SimpleStorage
.
address
,
data
:
SimpleStorage
.
interface
.
encodeFunctionData
(
'
set
'
,
[
'
0x
'
+
'
33
'
.
repeat
(
32
),
'
0x
'
+
'
44
'
.
repeat
(
32
),
]),
value
:
hre
.
ethers
.
BigNumber
.
from
(
0
),
},
{
target
:
SimpleStorage
.
address
,
data
:
SimpleStorage
.
interface
.
encodeFunctionData
(
'
set
'
,
[
'
0x
'
+
'
44
'
.
repeat
(
32
),
'
0x
'
+
'
55
'
.
repeat
(
32
),
]),
value
:
hre
.
ethers
.
BigNumber
.
from
(
0
),
},
],
})
await
Drippie
.
status
(
DEFAULT_DRIP_NAME
,
2
)
// ACTIVE
await
Drippie
.
drip
(
DEFAULT_DRIP_NAME
)
expect
(
await
SimpleStorage
.
get
(
'
0x
'
+
'
33
'
.
repeat
(
32
))).
to
.
equal
(
'
0x
'
+
'
44
'
.
repeat
(
32
)
)
expect
(
await
SimpleStorage
.
get
(
'
0x
'
+
'
44
'
.
repeat
(
32
))).
to
.
equal
(
'
0x
'
+
'
55
'
.
repeat
(
32
)
)
})
it
(
'
should revert if dripping twice in one interval
'
,
async
()
=>
{
await
Drippie
.
create
(
DEFAULT_DRIP_NAME
,
DEFAULT_DRIP_CONFIG
)
await
Drippie
.
status
(
DEFAULT_DRIP_NAME
,
2
)
// ACTIVE
await
Drippie
.
drip
(
DEFAULT_DRIP_NAME
)
await
expect
(
Drippie
.
drip
(
DEFAULT_DRIP_NAME
)).
to
.
be
.
revertedWith
(
'
Drippie: drip interval has not elapsed
'
)
await
hre
.
ethers
.
provider
.
send
(
'
evm_increaseTime
'
,
[
DEFAULT_DRIP_CONFIG
.
interval
.
add
(
1
).
toHexString
(),
])
await
expect
(
Drippie
.
drip
(
DEFAULT_DRIP_NAME
)).
to
.
not
.
be
.
reverted
})
it
(
'
should revert when the drip does not exist
'
,
async
()
=>
{
await
expect
(
Drippie
.
drip
(
DEFAULT_DRIP_NAME
)).
to
.
be
.
revertedWith
(
'
Drippie: selected drip does not exist or is not currently active
'
)
})
it
(
'
should revert when the drip is not active
'
,
async
()
=>
{
await
Drippie
.
create
(
DEFAULT_DRIP_NAME
,
DEFAULT_DRIP_CONFIG
)
await
expect
(
Drippie
.
drip
(
DEFAULT_DRIP_NAME
)).
to
.
be
.
revertedWith
(
'
Drippie: selected drip does not exist or is not currently active
'
)
})
})
})
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