- 
                Notifications
    You must be signed in to change notification settings 
- Fork 6
Add bootstrap test in maintennaceMode #587
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
base: eth-rollup-develop
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -7,7 +7,7 @@ import { hexToU8a } from "@polkadot/util"; | |
| import { getApi, initApi } from "../../utils/api"; | ||
| import { Assets } from "../../utils/Assets"; | ||
| import { GASP_ASSET_ID } from "../../utils/Constants"; | ||
| import { MangataGenericEvent } from "gasp-sdk"; | ||
| import { BN_HUNDRED_BILLIONS, MangataGenericEvent, toBN } from "gasp-sdk"; | ||
| import { BN } from "@polkadot/util"; | ||
| import { setupApi, setupUsers, sudo } from "../../utils/setup"; | ||
| import { Sudo } from "../../utils/sudo"; | ||
|  | @@ -20,6 +20,16 @@ import { testLog } from "../../utils/Logger"; | |
| import { checkMaintenanceStatus } from "../../utils/validators"; | ||
| import { Market } from "../../utils/market"; | ||
| import { FoundationMembers } from "../../utils/FoundationMembers"; | ||
| import { | ||
| checkLastBootstrapFinalized, | ||
| claimRewardsBootstrap, | ||
| createNewBootstrapCurrency, | ||
| provisionBootstrap, | ||
| scheduleBootstrap, | ||
| setupBootstrapTokensBalance, | ||
| waitForBootstrapStatus, | ||
| } from "../../utils/Bootstrap"; | ||
| import { xykErrors } from "../../utils/utils"; | ||
|  | ||
| jest.spyOn(console, "log").mockImplementation(jest.fn()); | ||
| jest.setTimeout(2500000); | ||
|  | @@ -264,3 +274,75 @@ async function getSudoError( | |
|  | ||
| expect(sudoEventError.name).toEqual(expectedError); | ||
| } | ||
|  | ||
| test("maintenance- bootstrap can be run in maintenanceMode, but you can't provide it and the pool will not be created", async () => { | ||
| await checkMaintenanceStatus(false, false); | ||
| await checkLastBootstrapFinalized(sudo); | ||
| const bootstrapCurrency = await createNewBootstrapCurrency(sudo); | ||
| const waitingPeriod = 10; | ||
| const bootstrapPeriod = 8; | ||
|  | ||
| [testUser1] = setupUsers(); | ||
|  | ||
| await setupBootstrapTokensBalance(bootstrapCurrency, sudo, [testUser1]); | ||
|  | ||
| await sudo.mint(bootstrapCurrency, testUser1, toBN("1", 20)); | ||
|  | ||
| await Sudo.batchAsSudoFinalized( | ||
| Sudo.sudoAsWithAddressString( | ||
| foundationAccountAddress, | ||
| Maintenance.switchMaintenanceModeOn(), | ||
| ), | ||
| ); | ||
|  | ||
| await checkMaintenanceStatus(true, false); | ||
|  | ||
| await scheduleBootstrap( | ||
| sudo, | ||
| GASP_ASSET_ID, | ||
| bootstrapCurrency, | ||
| waitingPeriod, | ||
| bootstrapPeriod, | ||
| ).then((result) => { | ||
| const eventResponse = getEventResultFromMangataTx(result); | ||
| expect(eventResponse.state).toEqual(ExtrinsicResult.ExtrinsicSuccess); | ||
| }); | ||
|  | ||
| await waitForBootstrapStatus("Public", waitingPeriod); | ||
|  | ||
| // check that user can make provision while bootstrap running | ||
| await provisionBootstrap( | ||
| testUser1, | ||
| bootstrapCurrency, | ||
| BN_HUNDRED_BILLIONS, | ||
| ).then((result) => { | ||
| const eventResponse = getEventResultFromMangataTx(result); | ||
| expect(eventResponse.state).toEqual(ExtrinsicResult.ExtrinsicFailed); | ||
| expect(eventResponse.data).toEqual("ProvisioningBlockedByMaintenanceMode"); | ||
| }); | ||
|  | ||
| await waitForBootstrapStatus("Finished", bootstrapPeriod); | ||
| await claimRewardsBootstrap(testUser1).then((result) => { | ||
| const eventResponse = getEventResultFromMangataTx(result); | ||
| expect(eventResponse.state).toEqual(ExtrinsicResult.ExtrinsicFailed); | ||
| expect(eventResponse.data).toEqual(xykErrors.MathOverflow); | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wow. math overflow? :O There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is because the amount is  | ||
| }); | ||
|  | ||
| const foundationSwitchModeEvents = await Sudo.batchAsSudoFinalized( | ||
| Sudo.sudoAsWithAddressString( | ||
| foundationAccountAddress, | ||
| Maintenance.switchMaintenanceModeOff(), | ||
| ), | ||
| ); | ||
|  | ||
| const filteredEvent = foundationSwitchModeEvents.filter( | ||
| (extrinsicResult) => extrinsicResult.method === "SudoAsDone", | ||
| ); | ||
| const eventIndex = JSON.parse(JSON.stringify(filteredEvent[0].event.data[0])); | ||
| expect(eventIndex.ok).toBeDefined(); | ||
|  | ||
| const poolId = await getLiquidityAssetId(GASP_ASSET_ID, bootstrapCurrency); | ||
| expect(poolId).bnEqual(new BN(-1)); | ||
| 
      Comment on lines
    
      +357
     to 
      +358
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this can be a side effect of no one being able to provide liq. Can you do another test that starts maintenance after a a provision being done? ie: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The scenario was created, but we have a bug here https://mangatafinance.atlassian.net/browse/GASP-2210 | ||
| await checkMaintenanceStatus(false, false); | ||
| await checkLastBootstrapFinalized(sudo); | ||
| }); | ||
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.
reuse the Asset.mint and add it to the next batchAsSudoFinalize. One day we will get rid of this sudo.mint stuff.
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.
Done