Skip to content
This repository has been archived by the owner on Dec 13, 2019. It is now read-only.

Tooling for tests v1 (StructAbiEncoder, computeHash functions) #11

Merged
merged 5 commits into from
Aug 7, 2018

Conversation

mitchelljustin
Copy link
Contributor

  • New convenience class: StructAbiEncoder
  • Extract helper functions: computeStateHash and computeActionHash.
  • utils.ts: Rename some constants and remove some unused functions.
  • Migrated commitReveal.spec.ts

@mitchelljustin mitchelljustin changed the title Test tooling v1 (SolidityStruct, computeHash functions) Test tooling v1 (StructAbiEncoder, computeHash functions) Aug 3, 2018
}
definitions.push(definition);
}
const encoding = `tuple(${definitions.join(", ")})`;
Copy link
Member

Choose a reason for hiding this comment

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

It would be cool to extend this in the future to support encodings with nested tuples.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, shouldn't be hard to do

await multisig.deploy(masterAccount);
await masterAccount.sendTransaction({
to: multisig.address,
value: Utils.UNIT_ETH.mul(2)
value: ethers.utils.parseEther("2")
Copy link
Member

Choose a reason for hiding this comment

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

Passing thought: maybe we can have a wrapper around this to abstractly indicate 2 eth being used instead of having a utility function needing to parse it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean? EtherAmount(2)?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah something like that - def not a blocker by any means tho

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure that's an abstraction worth doing. Esp if all the other Ethereum tooling uses raw integers.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah it may add unneeded overhead to existing usable patterns. Again, just a passing thought - not worth reading too much into

Copy link
Contributor

@snario snario Aug 7, 2018

Choose a reason for hiding this comment

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

Maybe just a shorthand util

export const str2eth = ethers.utils.parseEther

@@ -91,7 +107,7 @@ export const setupTestEnv = (web3: any) => {
return { provider, unlockedAccount };
};

export function signMessage(message, wallet): [number, string, string] {
function signMessage(message, wallet): [number, string, string] {
Copy link
Member

Choose a reason for hiding this comment

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

Why privatize these? Are they not being used anywhere else?

Copy link
Contributor Author

@mitchelljustin mitchelljustin Aug 6, 2018

Choose a reason for hiding this comment

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

Yup, they're not

@ldct ldct changed the title Test tooling v1 (StructAbiEncoder, computeHash functions) Tooling for tests v1 (StructAbiEncoder, computeHash functions) Aug 5, 2018
);
app = {
const appContract = await deployContract(CommitRevealApp, masterAccount);
const app = {
Copy link
Contributor

Choose a reason for hiding this comment

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

We could write a type for this. addr is a 20 byte string, reduce could be a ethers.Interface.FunctionDefinition etc

Copy link
Contributor Author

@mitchelljustin mitchelljustin Aug 7, 2018

Choose a reason for hiding this comment

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

Already on it (next PR)

@mitchelljustin mitchelljustin merged commit 27b2845 into develop Aug 7, 2018
@cf19drofxots cf19drofxots deleted the mitch/test-tooling branch August 13, 2018 23:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants