-
Notifications
You must be signed in to change notification settings - Fork 31
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
Fix the unit tests for the nested map call #423
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work 👍 A few minor remarks
@@ -942,7 +949,7 @@ export interface TestContractParams< | |||
initialMaps?: M | |||
initialAsset?: Asset // default 1 ALPH | |||
testArgs: A | |||
existingContracts?: ContractState[] // default no existing contracts | |||
existingContracts?: (ContractState | ContractStateWithMaps)[] // default no existing contracts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since ContractStateWithMaps
extends ContractState
, we could just use ContractStateWithMaps
?
testArgs: params.testArgs === undefined ? {} : params.testArgs, | ||
existingContracts: (params.existingContracts ?? []).concat(contractStates) | ||
existingContracts: Array.prototype.concat(existingContracts, selfMapEntries, existingMapEntries) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems it's recommended to use existingContracts.concat(selfMapEntries, existingMapEntries)
return { | ||
...testResult, | ||
maps | ||
maps: allMaps.find((v) => v.address === selfAddress)?.maps | ||
} as TestContractResult<R, M> | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is a bit bloated. Let's maybe introduce a few utility functions.
We still need to keep the
initialMaps
in theTestContractParams
because we cannot put the contract state that needs to be tested intoexistingContracts
.