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 property tests for migrationPlanToSelectionWithdrawals. #2654

Merged

Conversation

jonathanknowles
Copy link
Member

@jonathanknowles jonathanknowles commented May 17, 2021

Issue Number

ADP-840

Overview

This PR:

  • provides missing test coverage for the migrationPlanToSelectionWithdrawals function.
  • fixes the order in which target addresses are assigned to outputs.

Background

Before this PR, the order in which target addresses were assigned to outputs was not cyclical, as expected:

target-address-cycling

@jonathanknowles jonathanknowles self-assigned this May 17, 2021
@jonathanknowles jonathanknowles force-pushed the jonathanknowles/test-migrationPlanToSelectionWithdrawals branch from aa63bc8 to 5c1cd04 Compare May 17, 2021 09:22
pidB = PoolId "B"
pidUnknown = PoolId "unknown"
knownPools = Set.fromList [pidA, pidB]
next = WalletDelegationNext
Copy link
Member Author

Choose a reason for hiding this comment

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

This where clause is a bit annoying: it should belong to the pool delegation tests, but its scope covers the entire property test suite for this module.

}
deriving (Generic, Eq, Ord)
deriving anyclass (NFData, Hashable)
deriving (Read, Show) via (Quiet Address)
Copy link
Member Author

Choose a reason for hiding this comment

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

This makes the output of show much more concise for values of type Address.

Instead of:

Address { unAddress = "XXXX" }

We now have:

Address "XXXX"

This makes the output of `show` much more concise for values of type `Address`.

Instead of:
```hs
Address { unAddress = "XXXX" }
```

We now have:
```hs
Address "XXXX"
```
This commit makes `migrationPlanToSelectionWithdrawals` assign target
addresses in an order that precisely matches the order specified by the
user.

For example, suppose the user specifies the following target addresses:

>>> [a1, a2, a3]

These addresses will be assigned to the generated outputs in the following
predictable cyclic order:

>>> [a1, a2, a3, a1, a2, a3, .. ]
…outputs.

In particular, we test that inputs and outputs are preserved in the
correct order.
@jonathanknowles jonathanknowles force-pushed the jonathanknowles/test-migrationPlanToSelectionWithdrawals branch from 5c1cd04 to ff468a0 Compare May 17, 2021 09:29
@@ -1887,7 +1889,7 @@ migrationPlanToSelectionWithdrawals plan rewardWithdrawal outputAddressesToCycle

outputAddressesRemaining :: [Address]
outputAddressesRemaining =
drop (length $ view #outputs migrationSelection) outputAddresses
drop (length outputsCovered) outputAddresses
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a fix, or is it equivalent?

Copy link
Member Author

Choose a reason for hiding this comment

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

Is this a fix, or is it equivalent?

It's equivalent.

I guess, strictly speaking, this should be in a separate commit, as it isn't part of the fix. But it seems too minor to create a separate commit just for that.

@jonathanknowles
Copy link
Member Author

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented May 17, 2021

Build succeeded:

@iohk-bors iohk-bors bot merged commit 1c2f851 into master May 17, 2021
@iohk-bors iohk-bors bot deleted the jonathanknowles/test-migrationPlanToSelectionWithdrawals branch May 17, 2021 12:21
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.

None yet

2 participants