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

Preliminary integration tests between Jormungandr <-> Network Layer (networkTip) #400

Merged
merged 6 commits into from
Jun 12, 2019

Conversation

KtorZ
Copy link
Member

@KtorZ KtorZ commented Jun 11, 2019

Issue Number

#219

Overview

  • I have slightly changed the behavior of waitForConnection to also wait for the network tip to become available.
  • I have added happy & negative test paths for networkTip
  • I have fixed a few things along the way, including configuration and API definition (cf commits)

Comments

@KtorZ KtorZ self-assigned this Jun 11, 2019
@KtorZ KtorZ requested a review from Anviking June 11, 2019 17:53
@KtorZ KtorZ mentioned this pull request Jun 11, 2019
12 tasks
@@ -63,8 +61,6 @@ instance Exception ErrNetworkUnreachable
data ErrNetworkTip
= ErrNetworkTipNetworkUnreachable ErrNetworkUnreachable
| ErrNetworkTipNotFound
| ErrNetworkTipBlockNotFound (Hash "BlockHeader")
-- ^ The tip-block wasn't found. This would be surprising.
Copy link
Member Author

Choose a reason for hiding this comment

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

Not needed. This is in the end, an implementation details which can be seen as NetworkTipNotFound from the external perspective.

Copy link
Member

Choose a reason for hiding this comment

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

🤔 They are different though. ErrNetworkTipNotFound is expected to be thrown when the http-bridge is started without the chain. ErrNetworkTipBlockNotFound means "the impossible just happened".

Copy link
Member Author

Choose a reason for hiding this comment

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

But they pretty much means the same for us in the end: there's no tip. We won't do anything special when the corresponding block isn't found bit treat that as if there was no tip.

KtorZ added 6 commits June 11, 2019 20:11
The prefix is part of the node's configuration file, so it can be changed at will and therefore,
hasn't its place in the API definition. Instead, it should be passed alongside the 'BaseUrl' given to
the Jormungandr manager
@KtorZ KtorZ force-pushed the KtorZ/jormungandr-network-tip-tests branch from af06b91 to 37d95bb Compare June 11, 2019 18:14
Copy link
Member

@Anviking Anviking left a comment

Choose a reason for hiding this comment

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

lgtm — most pressingly wondering if we shouldn't run jormungandr in-memory

I am also (still?) suspicious/confused about NetworkLayer error types, but that's not specifically related to this pr

@@ -63,8 +61,6 @@ instance Exception ErrNetworkUnreachable
data ErrNetworkTip
= ErrNetworkTipNetworkUnreachable ErrNetworkUnreachable
| ErrNetworkTipNotFound
| ErrNetworkTipBlockNotFound (Hash "BlockHeader")
-- ^ The tip-block wasn't found. This would be surprising.
Copy link
Member

Choose a reason for hiding this comment

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

🤔 They are different though. ErrNetworkTipNotFound is expected to be thrown when the http-bridge is started without the chain. ErrNetworkTipBlockNotFound means "the impossible just happened".

lib/jormungandr/src/Cardano/Wallet/Jormungandr/Network.hs Outdated Show resolved Hide resolved

-- | A default 'RetryPolicy' with a constant delay, but no longer than 20
Copy link
Member

Choose a reason for hiding this comment

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

Seems confusing to say that the "constant delay" "is limited". Lazy suggestion:

Suggested change
-- | A default 'RetryPolicy' with a constant delay, but no longer than 20
-- | A default 'RetryPolicy' with a constant delay, but retries for no longer than 20

import Test.Hspec
( Spec, describe, expectationFailure, it )

spec :: Spec
spec = describe "cardano-wallet-launcher" $ do
it "Can start launcher against testnet" $ do
removePathForcibly "/tmp/cardano-wallet-jormungandr"
Copy link
Member

Choose a reason for hiding this comment

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

Should we remove the storage from the Jörmungandr config, to use in-memory instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmmm. No. Ideally integration tests reproduce the production setup as close as possible. This means, among othert things, using file based storage.

lib/core/src/Cardano/Wallet/Network.hs Show resolved Hide resolved
Copy link
Contributor

@paweljakubas paweljakubas left a comment

Choose a reason for hiding this comment

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

LGTM! I am also in favour of using only ErrNetworkTipNotFound and ignoring ErrNetworkTipBlockNotFound (Hash "BlockHeader") provided we know for sure the error I write below is eliminated. To my understand we get header hash of tip of block so having the tip means we have header hash of the tip. Nevertheless, basing on my experience when playing extensively with diffusion layer of cardano-sl, something else can pop out. Very rarely, but quite enough to detect it in the tests I encountered the error when calling requestTip :

BlockNetLogicException: DialogUnexpected "peer sent more than one tip"

Presumably, in new Shelly haskell node it is addressed but if not, we should remember about it when having obscure errors.

@KtorZ
Copy link
Member Author

KtorZ commented Jun 12, 2019

@pawel.jakubas @Anviking

This ErrNetworkTipBlockNotFound is a nice example of warning log severity IMO. Instead of returning a new error type that we are going to treat like the absence of tip anyway, I'd suggest to have a warning log line mentioning this bit still, returning a network tip not found error.

@KtorZ KtorZ merged commit 7548ec5 into master Jun 12, 2019
@KtorZ
Copy link
Member Author

KtorZ commented Jun 12, 2019

@Anviking Merging without the comment suggestion (will do in another PR)

@KtorZ KtorZ deleted the KtorZ/jormungandr-network-tip-tests branch June 12, 2019 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants