-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(isregistereduser): fetch events in batches
- Loading branch information
Showing
26 changed files
with
286 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { expect } from "chai"; | ||
import { Signer } from "ethers"; | ||
import { getDefaultSigner } from "maci-contracts"; | ||
import { Keypair } from "maci-domainobjs"; | ||
|
||
import { | ||
deploy, | ||
DeployedContracts, | ||
deployVkRegistryContract, | ||
isRegisteredUser, | ||
setVerifyingKeys, | ||
signup, | ||
} from "../../ts"; | ||
import { deployArgs, setVerifyingKeysArgs } from "../constants"; | ||
|
||
describe("signup", () => { | ||
let signer: Signer; | ||
let maciAddresses: DeployedContracts; | ||
const user = new Keypair(); | ||
// before all tests we deploy the vk registry contract and set the verifying keys | ||
before(async () => { | ||
signer = await getDefaultSigner(); | ||
|
||
// we deploy the vk registry contract | ||
await deployVkRegistryContract({ signer }); | ||
// we set the verifying keys | ||
await setVerifyingKeys({ ...setVerifyingKeysArgs, signer }); | ||
// deploy the smart contracts | ||
maciAddresses = await deploy({ ...deployArgs, signer }); | ||
}); | ||
|
||
it("should allow to signup and return the user data", async () => { | ||
const signUpData = await signup({ | ||
maciAddress: maciAddresses.maciAddress, | ||
maciPubKey: user.pubKey.serialize(), | ||
signer, | ||
}); | ||
|
||
const registeredUserData = await isRegisteredUser({ | ||
maciAddress: maciAddresses.maciAddress, | ||
startBlock: await signer.provider?.getBlockNumber(), | ||
maciPubKey: user.pubKey.serialize(), | ||
signer, | ||
}); | ||
|
||
expect(registeredUserData.isRegistered).to.eq(true); | ||
expect(registeredUserData.stateIndex).to.eq(signUpData.stateIndex); | ||
}); | ||
|
||
it("should not get the user data if the user is not registered", async () => { | ||
const registeredUserData = await isRegisteredUser({ | ||
maciAddress: maciAddresses.maciAddress, | ||
startBlock: await signer.provider?.getBlockNumber(), | ||
maciPubKey: new Keypair().pubKey.serialize(), | ||
signer, | ||
}); | ||
|
||
expect(registeredUserData.isRegistered).to.eq(false); | ||
}); | ||
|
||
it("should start fetchig from block zero if the start block is not provided", async () => { | ||
const registeredUserData = await isRegisteredUser({ | ||
maciAddress: maciAddresses.maciAddress, | ||
maciPubKey: user.pubKey.serialize(), | ||
signer, | ||
}); | ||
|
||
expect(registeredUserData.isRegistered).to.eq(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.