Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an extra scenario to illustrate the delegation "latency" #1137

Merged
merged 3 commits into from
Dec 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -251,20 +251,46 @@ spec = do
, expectListItemFieldEqual 1 status InLedger
]

waitForNextEpoch ctx
waitForNextEpoch ctx
reward <- getFromResponse balanceReward <$>
request @ApiWallet ctx (getWalletEp w) Default Empty

-- Wait an epoch and make sure the reward doesn't increase
epoch <- getFromResponse (#networkTip . #epochNumber) <$>
request @ApiNetworkInformation ctx networkInfoEp Default Empty
eventually $ do
epoch' <- getFromResponse (#networkTip . #epochNumber) <$>
request @ApiNetworkInformation ctx networkInfoEp Default Empty
unless (getApiT epoch' > getApiT epoch) $ fail "not yet"
waitForNextEpoch ctx
request @ApiWallet ctx (getWalletEp w) Default Empty >>= flip verify
[ expectFieldSatisfy balanceReward (== reward)
]

it "STAKE_POOLS_JOIN_04 -\
\Delegate, stop in the next epoch, and still earn rewards" $ \ctx -> do
w <- fixtureWallet ctx
(_, p1:_) <- eventually $
unsafeRequest @[ApiStakePool] ctx listStakePoolsEp Empty

joinStakePool ctx (p1 ^. #id) (w, fixturePassphrase) >>= flip verify
[ expectResponseCode HTTP.status202
]

waitForNextEpoch ctx

quitStakePool ctx (p1 ^. #id) (w, fixturePassphrase) >>= flip verify
[ expectResponseCode HTTP.status202
]

reward <- eventually $ do
r <- request @ApiWallet ctx (getWalletEp w) Default Empty
verify r
[ expectFieldSatisfy balanceReward (> 0)
]
pure $ getFromResponse balanceReward r

waitForNextEpoch ctx

eventually $ do
request @ApiWallet ctx (getWalletEp w) Default Empty >>= flip verify
[ expectFieldSatisfy balanceReward (== reward)
]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be worth also to waitForNextEpoch ctx after the last request/assertion and make sure that the rewards are still the same?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See 48ca283

it "STAKE_POOLS_JOIN_01 - I can join another stake-pool after previously \
\ joining another one" $ \ctx -> do
w <- fixtureWallet ctx
Expand Down Expand Up @@ -628,6 +654,17 @@ arbitraryPoolId :: ApiT PoolId
arbitraryPoolId = either (error . show) ApiT $ fromText
"a659052d84ddb6a04189bee523d59c0a3385c921f43db5dc5de17a4f3f11dc4c"

waitForNextEpoch
:: Context t
-> IO ()
waitForNextEpoch ctx = do
epoch <- getFromResponse (#nodeTip . #epochNumber) <$>
request @ApiNetworkInformation ctx networkInfoEp Default Empty
eventually $ do
epoch' <- getFromResponse (#nodeTip . #epochNumber) <$>
request @ApiNetworkInformation ctx networkInfoEp Default Empty
unless (getApiT epoch' > getApiT epoch) $ fail "not yet"

joinStakePoolWithWalletBalance
:: (Context t)
-> [Natural]
Expand Down