Skip to content

Commit 0900c1f

Browse files
authored
update tests for new ocean.js 2.0 (#526)
* update tests for new ocean.js 2.0 * add tx&block to veDeposit * add veOcean tests * bump to oceanlib 2.0.0
1 parent 2c54594 commit 0900c1f

13 files changed

+424
-53
lines changed

package-lock.json

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"test-dispenser": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/Dispenser.test.ts'",
2828
"test-fixed": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/FixedRateExchange.test.ts'",
2929
"test-users": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/users.test.ts'",
30+
"test-ve": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/VeOcean.test.ts'",
3031
"lint": "eslint --ignore-path .gitignore --ext .js --ext .ts --ext .tsx .",
3132
"lint:fix": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx . --fix",
3233
"format": "prettier --ignore-path .gitignore './**/*.{css,yml,js,ts,tsx,json,yaml}' --write",
@@ -65,7 +66,7 @@
6566
},
6667
"dependencies": {
6768
"@oceanprotocol/contracts": "^1.1.3",
68-
"@oceanprotocol/lib": "^1.1.8",
69+
"@oceanprotocol/lib": "^2.0.0",
6970
"cross-fetch": "^3.1.4"
7071
},
7172
"repository": {

schema.graphql

+2
Original file line numberDiff line numberDiff line change
@@ -461,4 +461,6 @@ type VeDeposit @entity {
461461
unlockTime: BigInt!
462462
type:BigInt!
463463
timestamp: BigInt!
464+
block: Int!
465+
tx: String!
464466
}

src/mappings/utils/veUtils.ts

+2
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ export function getDeposit(id: string): VeDeposit {
141141
deposit.unlockTime = BigInt.zero()
142142
deposit.type = BigInt.zero()
143143
deposit.timestamp = BigInt.zero()
144+
deposit.tx = ''
145+
deposit.block = 0
144146
deposit.save()
145147
}
146148
return deposit

src/mappings/veOCEAN.ts

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export function handleDeposit(event: Deposit): void {
1616
deposit.unlockTime = locktime
1717
deposit.type = type
1818
deposit.timestamp = ts
19+
deposit.block = event.block.number.toI32()
20+
deposit.tx = event.transaction.hash.toHex()
1921
deposit.save()
2022
// --------------------------------------------
2123

test/integration/Datatoken.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
Erc20CreateParams,
2+
DatatokenCreateParams,
33
ProviderInstance,
44
Nft,
55
NftFactory,
@@ -117,7 +117,7 @@ describe('Datatoken tests', async () => {
117117
transferable: true,
118118
owner: publisher
119119
}
120-
const erc20Params: Erc20CreateParams = {
120+
const erc20Params: DatatokenCreateParams = {
121121
templateIndex,
122122
cap,
123123
feeAmount: publishMarketFeeAmount,
@@ -126,7 +126,7 @@ describe('Datatoken tests', async () => {
126126
minter: publisher,
127127
mpFeeAddress: marketPlaceFeeAddress
128128
}
129-
const result = await Factory.createNftWithErc20(
129+
const result = await Factory.createNftWithDatatoken(
130130
publisher,
131131
nftParams,
132132
erc20Params
@@ -343,7 +343,7 @@ describe('Datatoken tests', async () => {
343343
transferable: true,
344344
owner: publisher
345345
}
346-
const erc20Params: Erc20CreateParams = {
346+
const erc20Params: DatatokenCreateParams = {
347347
templateIndex,
348348
cap: '100000',
349349
feeAmount: '0',
@@ -352,7 +352,7 @@ describe('Datatoken tests', async () => {
352352
minter: publisher,
353353
mpFeeAddress: ZERO_ADDRESS
354354
}
355-
const result = await Factory.createNftWithErc20(
355+
const result = await Factory.createNftWithDatatoken(
356356
publisher,
357357
nftParams,
358358
erc20Params

test/integration/Dispenser.test.ts

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
Erc20CreateParams,
2+
DatatokenCreateParams,
33
NftFactory,
44
NftCreateData,
55
sleep,
@@ -70,15 +70,16 @@ describe('Dispenser tests', async () => {
7070

7171
it('should initialize Dispenser and datatoken class', async () => {
7272
dispenser = new Dispenser(
73+
addresses.Dispenser,
7374
web3,
7475
8996,
75-
addresses.Dispenser,
76+
null,
7677
DispenserTemplate.abi as AbiItem[]
7778
)
78-
assert(dispenser.dispenserAbi !== null)
79+
assert(dispenser.getDefaultAbi() !== null)
7980

80-
datatoken = new Datatoken(web3, 8996, ERC20Template.abi as AbiItem[])
81-
assert(datatoken.datatokensAbi !== null)
81+
datatoken = new Datatoken(web3, 8996, null, ERC20Template.abi as AbiItem[])
82+
assert(datatoken.getDefaultAbi() !== null)
8283
})
8384

8485
it('Deploying an NFT with ERC20', async () => {
@@ -94,7 +95,7 @@ describe('Dispenser tests', async () => {
9495
transferable: true,
9596
owner: publisher
9697
}
97-
const erc20Params: Erc20CreateParams = {
98+
const erc20Params: DatatokenCreateParams = {
9899
templateIndex,
99100
cap,
100101
feeAmount,
@@ -104,7 +105,7 @@ describe('Dispenser tests', async () => {
104105
mpFeeAddress: marketPlaceFeeAddress
105106
}
106107

107-
const tx = await Factory.createNftWithErc20(
108+
const tx = await Factory.createNftWithDatatoken(
108109
publisher,
109110
nftParams,
110111
erc20Params
@@ -263,7 +264,7 @@ describe('Dispenser tests', async () => {
263264
it('Make user1 minter', async () => {
264265
await datatoken.addMinter(dtAddress, publisher, user1)
265266

266-
assert((await datatoken.getDTPermissions(dtAddress, user1)).minter === true)
267+
assert((await datatoken.getPermissions(dtAddress, user1)).minter === true)
267268
await sleep(sleepMs)
268269
const minterQuery = {
269270
query: `query {token(id: "${dtAddress}"){minter{id}}}`

test/integration/FixedRateExchange.test.ts

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
Erc20CreateParams,
2+
DatatokenCreateParams,
33
NftFactory,
44
NftCreateData,
55
sleep,
@@ -89,7 +89,7 @@ describe('Fixed Rate Exchange tests', async () => {
8989
transferable: true,
9090
owner: publisher
9191
}
92-
const erc20Params: Erc20CreateParams = {
92+
const erc20Params: DatatokenCreateParams = {
9393
templateIndex,
9494
cap,
9595
feeAmount,
@@ -111,7 +111,7 @@ describe('Fixed Rate Exchange tests', async () => {
111111
withMint: false
112112
}
113113

114-
const result = await Factory.createNftErc20WithFixedRate(
114+
const result = await Factory.createNftWithDatatokenWithFixedRate(
115115
publisher,
116116
nftParams,
117117
erc20Params,
@@ -392,7 +392,7 @@ describe('Fixed Rate Exchange tests', async () => {
392392
})
393393

394394
it('Updates Fixed Rate Price', async () => {
395-
fixedRate = new FixedRateExchange(web3, fixedRateAddress, 8996)
395+
fixedRate = new FixedRateExchange(fixedRateAddress, web3, 8996)
396396
const priceQuery = {
397397
query: `query {fixedRateExchange(id: "${fixedRateId}"){
398398
price
@@ -627,8 +627,9 @@ describe('Fixed Rate Exchange tests', async () => {
627627
let user1Balance = await datatoken.balance(datatokenAddress, user1)
628628
assert(user1Balance === '0', 'incorrect value for: user1Balance')
629629

630-
const tx = (await fixedRate.buyDT(user1, exchangeId, dtAmount, '100'))
631-
.events?.Swapped
630+
const tx = (
631+
await fixedRate.buyDatatokens(user1, exchangeId, dtAmount, '100')
632+
).events?.Swapped
632633
await sleep(sleepMs)
633634
user1Balance = await datatoken.balance(datatokenAddress, user1)
634635
// user1 has 1 datatoken
@@ -656,8 +657,8 @@ describe('Fixed Rate Exchange tests', async () => {
656657
})
657658
it('User1 sells a datatoken', async () => {
658659
await datatoken.approve(datatokenAddress, fixedRateAddress, dtAmount, user1)
659-
const tx = (await fixedRate.sellDT(user1, exchangeId, '10', '9')).events
660-
?.Swapped
660+
const tx = (await fixedRate.sellDatatokens(user1, exchangeId, '10', '9'))
661+
.events?.Swapped
661662
assert(tx != null)
662663
await sleep(sleepMs)
663664
const swapsQuery = {

test/integration/Nft.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
Erc20CreateParams,
2+
DatatokenCreateParams,
33
ProviderInstance,
44
Nft,
55
NftFactory,
@@ -103,7 +103,7 @@ describe('NFT tests', async () => {
103103
transferable: true,
104104
owner: publisher
105105
}
106-
const erc20Params: Erc20CreateParams = {
106+
const erc20Params: DatatokenCreateParams = {
107107
templateIndex: 1,
108108
cap: '100000',
109109
feeAmount: '0',
@@ -112,7 +112,7 @@ describe('NFT tests', async () => {
112112
minter: publisher,
113113
mpFeeAddress: '0x0000000000000000000000000000000000000000'
114114
}
115-
const result = await Factory.createNftWithErc20(
115+
const result = await Factory.createNftWithDatatoken(
116116
publisher,
117117
nftParams,
118118
erc20Params

test/integration/SimplePublishConsume.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
Datatoken,
3-
Erc20CreateParams,
3+
DatatokenCreateParams,
44
ProviderInstance,
55
ProviderFees,
66
Nft,
@@ -105,7 +105,7 @@ describe('Simple Publish & consume test', async () => {
105105
transferable: true,
106106
owner: publisherAccount
107107
}
108-
const erc20Params: Erc20CreateParams = {
108+
const erc20Params: DatatokenCreateParams = {
109109
templateIndex: 1,
110110
cap: '100000',
111111
feeAmount: '0',
@@ -114,7 +114,7 @@ describe('Simple Publish & consume test', async () => {
114114
minter: publisherAccount,
115115
mpFeeAddress: '0x0000000000000000000000000000000000000000'
116116
}
117-
const result = await Factory.createNftWithErc20(
117+
const result = await Factory.createNftWithDatatoken(
118118
publisherAccount,
119119
nftParams,
120120
erc20Params
@@ -170,7 +170,7 @@ describe('Simple Publish & consume test', async () => {
170170
transferable: true,
171171
owner: publisherAccount
172172
}
173-
const erc20Params: Erc20CreateParams = {
173+
const erc20Params: DatatokenCreateParams = {
174174
templateIndex: 1,
175175
cap: '100000',
176176
feeAmount: '0',
@@ -179,7 +179,7 @@ describe('Simple Publish & consume test', async () => {
179179
minter: publisherAccount,
180180
mpFeeAddress: '0x0000000000000000000000000000000000000000'
181181
}
182-
const result = await Factory.createNftWithErc20(
182+
const result = await Factory.createNftWithDatatoken(
183183
publisherAccount,
184184
nftParams,
185185
erc20Params

test/integration/SimpleSubgraph.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
Erc20CreateParams,
2+
DatatokenCreateParams,
33
Nft,
44
NftFactory,
55
NftCreateData,
@@ -49,7 +49,7 @@ describe('Tests coverage without provider/aquarius', async () => {
4949
transferable: true,
5050
owner: publisherAccount
5151
}
52-
const erc20Params: Erc20CreateParams = {
52+
const erc20Params: DatatokenCreateParams = {
5353
templateIndex: 1,
5454
cap: '100000',
5555
feeAmount: '0',
@@ -58,7 +58,7 @@ describe('Tests coverage without provider/aquarius', async () => {
5858
minter: publisherAccount,
5959
mpFeeAddress: '0x0000000000000000000000000000000000000000'
6060
}
61-
const result = await Factory.createNftWithErc20(
61+
const result = await Factory.createNftWithDatatoken(
6262
publisherAccount,
6363
nftParams,
6464
erc20Params
@@ -89,7 +89,7 @@ describe('Tests coverage without provider/aquarius', async () => {
8989
transferable: true,
9090
owner: publisherAccount
9191
}
92-
const erc20Params: Erc20CreateParams = {
92+
const erc20Params: DatatokenCreateParams = {
9393
templateIndex: 1,
9494
cap: '100000',
9595
feeAmount: '0',
@@ -98,7 +98,7 @@ describe('Tests coverage without provider/aquarius', async () => {
9898
minter: publisherAccount,
9999
mpFeeAddress: '0x0000000000000000000000000000000000000000'
100100
}
101-
const result = await Factory.createNftWithErc20(
101+
const result = await Factory.createNftWithDatatoken(
102102
publisherAccount,
103103
nftParams,
104104
erc20Params

0 commit comments

Comments
 (0)