-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from josejulio/expand-hydra-tests
Expand tests
- Loading branch information
Showing
14 changed files
with
456 additions
and
97 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
testTimeout: 60 * 1e3 | ||
testTimeout: 120 * 1e3 | ||
}; |
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 was deleted.
Oops, something went wrong.
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,111 @@ | ||
import { setupEnvironment } from "./setup"; | ||
import { Document } from './types/Document'; | ||
import { last } from './utils/Arrays'; | ||
import { getDocumentsByType } from './utils/Dao'; | ||
import { DocumentBuilder } from './utils/DocumentBuilder'; | ||
import { getDaoExpect } from './utils/Expect'; | ||
import { getAccountPermission } from './utils/Permissions'; | ||
|
||
describe('Proposal', () => { | ||
const getSampleRole = (title: string = 'Underwater Basketweaver'): Document => DocumentBuilder | ||
.builder() | ||
.contentGroup(builder => { | ||
builder | ||
.groupLabel('details') | ||
.string('title', title) | ||
.string('description', 'Weave baskets at the bottom of the sea') | ||
.asset('annual_usd_salary', '150000.00 USD') | ||
.int64('start_period', 0) | ||
.int64('end_period', 9) | ||
.int64('fulltime_capacity_x100', 100) | ||
.int64('min_time_share_x100', 50) | ||
.int64('min_deferred_x100', 50) | ||
}) | ||
.build(); | ||
|
||
it('Proposal failed', async() => { | ||
const environment = await setupEnvironment(); | ||
|
||
const now = new Date(); | ||
const whenVoteExpires = new Date(); | ||
whenVoteExpires.setSeconds( whenVoteExpires.getSeconds() + environment.settings.votingDurationSeconds + 1); | ||
|
||
environment.setCurrentTime(now); | ||
|
||
// Proposing | ||
await environment.dao.contract.propose({ | ||
proposer: environment.members[0].account.accountName, | ||
proposal_type: 'role', | ||
content_groups: getSampleRole().content_groups | ||
}); | ||
|
||
const proposal = last(getDocumentsByType( | ||
environment.getDaoDocuments(), | ||
'role' | ||
)); | ||
|
||
const daoExpect = getDaoExpect(environment); | ||
daoExpect.toHaveEdge(environment.getRoot(), proposal, 'proposal'); | ||
daoExpect.toHaveEdge(environment.members[0].doc, proposal, 'owns'); | ||
daoExpect.toHaveEdge(proposal, environment.members[0].doc, 'ownedby'); | ||
|
||
// Sets the time to the end of proposal | ||
environment.setCurrentTime(whenVoteExpires); | ||
|
||
// Now we can close the proposal | ||
await environment.dao.contract.closedocprop({ | ||
proposal_hash: proposal.hash | ||
}, getAccountPermission(environment.members[0].account)); | ||
|
||
daoExpect.toHaveEdge(environment.getRoot(), proposal, 'failedprops'); | ||
}); | ||
|
||
it('Proposal passes', async() => { | ||
const environment = await setupEnvironment(); | ||
|
||
const now = new Date(); | ||
const whenVoteExpires = new Date(); | ||
whenVoteExpires.setSeconds( whenVoteExpires.getSeconds() + environment.settings.votingDurationSeconds + 1); | ||
|
||
environment.setCurrentTime(now); | ||
|
||
// Proposing | ||
await environment.dao.contract.propose({ | ||
proposer: environment.members[0].account.accountName, | ||
proposal_type: 'role', | ||
content_groups: getSampleRole().content_groups | ||
}); | ||
|
||
let proposal = last(getDocumentsByType( | ||
environment.getDaoDocuments(), | ||
'role' | ||
)); | ||
|
||
const daoExpect = getDaoExpect(environment); | ||
daoExpect.toHaveEdge(environment.getRoot(), proposal, 'proposal'); | ||
daoExpect.toHaveEdge(environment.members[0].doc, proposal, 'owns'); | ||
daoExpect.toHaveEdge(proposal, environment.members[0].doc, 'ownedby'); | ||
|
||
await environment.dao.contract.vote({ | ||
voter: environment.members[0].account.accountName, | ||
proposal_hash: proposal.hash, | ||
vote: 'pass' | ||
}); | ||
|
||
// Sets the time to the end of proposal | ||
environment.setCurrentTime(whenVoteExpires); | ||
|
||
// Now we can close the proposal | ||
await environment.dao.contract.closedocprop({ | ||
proposal_hash: proposal.hash | ||
}, getAccountPermission(environment.members[0].account)); | ||
|
||
// When passing, the proposal is updated | ||
proposal = last(getDocumentsByType( | ||
environment.getDaoDocuments(), | ||
'role' | ||
)); | ||
|
||
daoExpect.toHaveEdge(environment.getRoot(), proposal, 'passedprops'); | ||
}); | ||
}); |
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,8 @@ | ||
export interface Edge { | ||
from_node: string; | ||
to_node: string; | ||
edge_name: string; | ||
created_date: string; | ||
creator: string; | ||
contract: string; | ||
} |
Oops, something went wrong.