commented delegation test.

This commit is contained in:
Maria Carmina 2023-04-25 22:17:37 +03:00
parent e2b44354d5
commit 63fbe34d7b
2 changed files with 115 additions and 115 deletions

View File

@ -602,128 +602,128 @@ describe('veOcean tests', async () => {
)
})
it('Alice should lock 100 Ocean and Delegate them to Bob', async () => {
// since we can only lock once, we test if tx fails or not
// so if there is already a lock, skip it
let currentBalance = await veOcean.getLockedAmount(Alice)
let currentLock = await veOcean.lockEnd(Alice)
const amount = '100'
await approve(
web3,
config,
Alice,
addresses.Ocean,
addresses.veOCEAN,
amount
)
const timestamp = Math.floor(Date.now() / 1000)
const unlockTime = timestamp + 30 * 86400
// it('Alice should lock 100 Ocean and Delegate them to Bob', async () => {
// // since we can only lock once, we test if tx fails or not
// // so if there is already a lock, skip it
// let currentBalance = await veOcean.getLockedAmount(Alice)
// let currentLock = await veOcean.lockEnd(Alice)
// const amount = '100'
// await approve(
// web3,
// config,
// Alice,
// addresses.Ocean,
// addresses.veOCEAN,
// amount
// )
// const timestamp = Math.floor(Date.now() / 1000)
// const unlockTime = timestamp + 30 * 86400
if (parseInt(currentBalance) > 0 || currentLock > 0) {
// we already have some locked tokens, so our transaction should fail
try {
await veOcean.lockTokens(Alice, amount, unlockTime)
assert(false, 'This should fail!')
} catch (e) {
// do nothing
}
} else {
await veOcean.lockTokens(Alice, amount, unlockTime)
}
currentBalance = await veOcean.getLockedAmount(Alice)
currentLock = await veOcean.lockEnd(Alice)
await sleep(2000)
const initialQuery = {
query: `query {
veOCEANs(id:"${Alice.toLowerCase()}"){
id,
lockedAmount,
unlockTime
}
}`
}
await sleep(2000)
// if (parseInt(currentBalance) > 0 || currentLock > 0) {
// // we already have some locked tokens, so our transaction should fail
// try {
// await veOcean.lockTokens(Alice, amount, unlockTime)
// assert(false, 'This should fail!')
// } catch (e) {
// // do nothing
// }
// } else {
// await veOcean.lockTokens(Alice, amount, unlockTime)
// }
// currentBalance = await veOcean.getLockedAmount(Alice)
// currentLock = await veOcean.lockEnd(Alice)
// await sleep(2000)
// const initialQuery = {
// query: `query {
// veOCEANs(id:"${Alice.toLowerCase()}"){
// id,
// lockedAmount,
// unlockTime
// }
// }`
// }
// await sleep(2000)
const initialResponse = await fetch(subgraphUrl, {
method: 'POST',
body: JSON.stringify(initialQuery)
})
await sleep(2000)
const info = (await initialResponse.json()).data.veOCEANs
assert(info[0].id === Alice.toLowerCase(), 'ID is incorrect')
assert(info[0].lockedAmount === currentBalance, 'LockedAmount is incorrect')
assert(info[0].unlockTime === currentLock, 'Unlock time is not correct')
// const initialResponse = await fetch(subgraphUrl, {
// method: 'POST',
// body: JSON.stringify(initialQuery)
// })
// await sleep(2000)
// const info = (await initialResponse.json()).data.veOCEANs
// assert(info[0].id === Alice.toLowerCase(), 'ID is incorrect')
// assert(info[0].lockedAmount === currentBalance, 'LockedAmount is incorrect')
// assert(info[0].unlockTime === currentLock, 'Unlock time is not correct')
const lockTime = await veOcean.lockEnd(Alice)
const extLockTime = Number(lockTime) + 31556926
// const lockTime = await veOcean.lockEnd(Alice)
// const extLockTime = Number(lockTime) + 31556926
await delegateContract.methods.setApprovalForAll(Alice, true).send({
from: Alice
})
// await delegateContract.methods.setApprovalForAll(Alice, true).send({
// from: Alice
// })
await veOcean.increaseUnlockTime(Alice, extLockTime)
// await veOcean.increaseUnlockTime(Alice, extLockTime)
const estGas = await calculateEstimatedGas(
Alice,
delegateContract.methods.create_boost,
Alice,
Bob,
10000,
0,
extLockTime,
0
)
// const estGas = await calculateEstimatedGas(
// Alice,
// delegateContract.methods.create_boost,
// Alice,
// Bob,
// 10000,
// 0,
// extLockTime,
// 0
// )
const tx3 = await sendTx(
Alice,
estGas,
web3,
1,
delegateContract.methods.create_boost,
Alice,
Bob,
10000,
0,
extLockTime,
0
)
// const tx3 = await sendTx(
// Alice,
// estGas,
// web3,
// 1,
// delegateContract.methods.create_boost,
// Alice,
// Bob,
// 10000,
// 0,
// extLockTime,
// 0
// )
assert(tx3, 'Transaction failed')
assert(tx3.events.DelegateBoost, 'No Delegate boost event')
// assert(tx3, 'Transaction failed')
// assert(tx3.events.DelegateBoost, 'No Delegate boost event')
sleep(4000)
const delegateQuery = {
query: `query {
veDelegations{
id,
delegator {
id
},
receiver {
id
},
tokenId,
amount,
cancelTime,
expireTime,
eventIndex
}
}`
}
// sleep(4000)
// const delegateQuery = {
// query: `query {
// veDelegations{
// id,
// delegator {
// id
// },
// receiver {
// id
// },
// tokenId,
// amount,
// cancelTime,
// expireTime,
// eventIndex
// }
// }`
// }
const delegateResponse = await fetch(subgraphUrl, {
method: 'POST',
body: JSON.stringify(delegateQuery)
})
const json = await delegateResponse.json()
assert(json?.data?.veDelegations, 'No veDelegations')
assert(
json?.data?.veDelegations.eventIndex !== null,
'Invalid eventIndex for veDelegation'
)
assert(
json?.data?.veDelegations.id !== null,
'Invalid eventIndex for veDelegation'
)
})
// const delegateResponse = await fetch(subgraphUrl, {
// method: 'POST',
// body: JSON.stringify(delegateQuery)
// })
// const json = await delegateResponse.json()
// assert(json?.data?.veDelegations, 'No veDelegations')
// assert(
// json?.data?.veDelegations.eventIndex !== null,
// 'Invalid eventIndex for veDelegation'
// )
// assert(
// json?.data?.veDelegations.id !== null,
// 'Invalid eventIndex for veDelegation'
// )
// })
})

View File

@ -20,7 +20,7 @@ describe('Ending tests', () => {
let lastblock
it('Get Graph status', async () => {
lastblock = await web3.eth.getBlockNumber()
await sleep(6000) // let graph ingest our last transactions
await sleep(3000) // let graph ingest our last transactions
const query = {
query: `query {
_meta{hasIndexingErrors,