mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
Support integration tests on networks without Dispenser.
This commit is contained in:
parent
9a6782cfa3
commit
bb082f0c8a
@ -19,9 +19,9 @@ before_script:
|
|||||||
- ganache-cli --port 18545 > ganache-cli.log &
|
- ganache-cli --port 18545 > ganache-cli.log &
|
||||||
- git clone https://github.com/oceanprotocol/barge
|
- git clone https://github.com/oceanprotocol/barge
|
||||||
- cd barge
|
- cd barge
|
||||||
- export AQUARIUS_VERSION=v0.2.9
|
- export AQUARIUS_VERSION=v0.3.4
|
||||||
- export BRIZO_VERSION=v0.3.10
|
- export BRIZO_VERSION=v0.3.12
|
||||||
- export KEEPER_VERSION=v0.9.7
|
- export KEEPER_VERSION=v0.10.3
|
||||||
- export KEEPER_OWNER_ROLE_ADDRESS="0xe2DD09d719Da89e5a3D0F2549c7E24566e947260"
|
- export KEEPER_OWNER_ROLE_ADDRESS="0xe2DD09d719Da89e5a3D0F2549c7E24566e947260"
|
||||||
- bash -x start_ocean.sh --no-pleuston --local-spree-node 2>&1 > start_ocean.log &
|
- bash -x start_ocean.sh --no-pleuston --local-spree-node 2>&1 > start_ocean.log &
|
||||||
- cd ..
|
- cd ..
|
||||||
|
@ -52,6 +52,5 @@ if (process.env.SEED_WORDS) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const config: Config & {forceVerbose: Config} = configJson as any
|
export const config: Config & { forceVerbose: Config } = configJson as any
|
||||||
|
;(config as any).forceVerbose = { ...configJson, verbose: true }
|
||||||
(config as any).forceVerbose = {...configJson, verbose: true}
|
|
||||||
|
@ -12,13 +12,17 @@ describe('Asset Owners', () => {
|
|||||||
let account1: Account
|
let account1: Account
|
||||||
let account2: Account
|
let account2: Account
|
||||||
|
|
||||||
const metadata = getMetadata()
|
let metadata = getMetadata()
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
ocean = await Ocean.getInstance(config)
|
ocean = await Ocean.getInstance(config)
|
||||||
|
|
||||||
// Accounts
|
// Accounts
|
||||||
;[account1, account2] = await ocean.accounts.list()
|
;[account1, account2] = await ocean.accounts.list()
|
||||||
|
|
||||||
|
if (!ocean.keeper.dispenser) {
|
||||||
|
metadata = getMetadata(0)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should be set correctly the owner of a asset', async () => {
|
it('should be set correctly the owner of a asset', async () => {
|
||||||
@ -59,9 +63,13 @@ describe('Asset Owners', () => {
|
|||||||
assert.equal(finalLength1 - initialLength, 0)
|
assert.equal(finalLength1 - initialLength, 0)
|
||||||
|
|
||||||
// Granting access
|
// Granting access
|
||||||
|
try {
|
||||||
await account2.requestTokens(
|
await account2.requestTokens(
|
||||||
+metadata.base.price * 10 ** -(await ocean.keeper.token.decimals())
|
+metadata.base.price *
|
||||||
|
10 ** -(await ocean.keeper.token.decimals())
|
||||||
)
|
)
|
||||||
|
} catch {}
|
||||||
|
|
||||||
await ocean.assets.order(
|
await ocean.assets.order(
|
||||||
ddo.id,
|
ddo.id,
|
||||||
ddo.findServiceByType('Access').serviceDefinitionId,
|
ddo.findServiceByType('Access').serviceDefinitionId,
|
||||||
|
@ -12,7 +12,7 @@ describe('Consume Asset', () => {
|
|||||||
let publisher: Account
|
let publisher: Account
|
||||||
let consumer: Account
|
let consumer: Account
|
||||||
|
|
||||||
const metadata = getMetadata()
|
let metadata = getMetadata()
|
||||||
|
|
||||||
let ddo: DDO
|
let ddo: DDO
|
||||||
let serviceAgreementSignatureResult: {
|
let serviceAgreementSignatureResult: {
|
||||||
@ -25,6 +25,10 @@ describe('Consume Asset', () => {
|
|||||||
|
|
||||||
// Accounts
|
// Accounts
|
||||||
;[publisher, consumer] = await ocean.accounts.list()
|
;[publisher, consumer] = await ocean.accounts.list()
|
||||||
|
|
||||||
|
if (!ocean.keeper.dispenser) {
|
||||||
|
metadata = getMetadata(0)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should regiester a asset', async () => {
|
it('should regiester a asset', async () => {
|
||||||
@ -47,7 +51,10 @@ describe('Consume Asset', () => {
|
|||||||
const initialBalance = (await consumer.getBalance()).ocn
|
const initialBalance = (await consumer.getBalance()).ocn
|
||||||
const claimedTokens =
|
const claimedTokens =
|
||||||
+metadata.base.price * 10 ** -(await ocean.keeper.token.decimals())
|
+metadata.base.price * 10 ** -(await ocean.keeper.token.decimals())
|
||||||
|
|
||||||
|
try {
|
||||||
await consumer.requestTokens(claimedTokens)
|
await consumer.requestTokens(claimedTokens)
|
||||||
|
} catch {}
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
(await consumer.getBalance()).ocn,
|
(await consumer.getBalance()).ocn,
|
||||||
|
@ -15,13 +15,17 @@ describe('Consume Asset (Brizo)', () => {
|
|||||||
let ddo: DDO
|
let ddo: DDO
|
||||||
let agreementId: string
|
let agreementId: string
|
||||||
|
|
||||||
const metadata = getMetadata()
|
let metadata = getMetadata()
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
ocean = await Ocean.getInstance(config)
|
ocean = await Ocean.getInstance(config)
|
||||||
|
|
||||||
// Accounts
|
// Accounts
|
||||||
;[publisher, consumer] = await ocean.accounts.list()
|
;[publisher, consumer] = await ocean.accounts.list()
|
||||||
|
|
||||||
|
if (!ocean.keeper.dispenser) {
|
||||||
|
metadata = getMetadata(0)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
after(() => {
|
after(() => {
|
||||||
@ -48,9 +52,12 @@ describe('Consume Asset (Brizo)', () => {
|
|||||||
it('should order the asset', async () => {
|
it('should order the asset', async () => {
|
||||||
const accessService = ddo.findServiceByType('Access')
|
const accessService = ddo.findServiceByType('Access')
|
||||||
|
|
||||||
|
try {
|
||||||
await consumer.requestTokens(
|
await consumer.requestTokens(
|
||||||
+metadata.base.price * 10 ** -(await ocean.keeper.token.decimals())
|
+metadata.base.price *
|
||||||
|
10 ** -(await ocean.keeper.token.decimals())
|
||||||
)
|
)
|
||||||
|
} catch {}
|
||||||
|
|
||||||
const steps = []
|
const steps = []
|
||||||
agreementId = await ocean.assets
|
agreementId = await ocean.assets
|
||||||
|
@ -16,8 +16,19 @@ xdescribe('Consume Asset (Large size)', () => {
|
|||||||
let ddo: DDO
|
let ddo: DDO
|
||||||
let agreementId: string
|
let agreementId: string
|
||||||
|
|
||||||
const baseMetadata = getMetadata()
|
let baseMetadata = getMetadata()
|
||||||
const metadata = {
|
let metadata = getMetadata()
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
ocean = await Ocean.getInstance(config)
|
||||||
|
|
||||||
|
// Accounts
|
||||||
|
;[publisher, consumer] = await ocean.accounts.list()
|
||||||
|
|
||||||
|
if (!ocean.keeper.dispenser) {
|
||||||
|
baseMetadata = getMetadata(0)
|
||||||
|
}
|
||||||
|
metadata = {
|
||||||
...baseMetadata,
|
...baseMetadata,
|
||||||
base: {
|
base: {
|
||||||
...baseMetadata.base,
|
...baseMetadata.base,
|
||||||
@ -28,12 +39,6 @@ xdescribe('Consume Asset (Large size)', () => {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
before(async () => {
|
|
||||||
ocean = await Ocean.getInstance(config)
|
|
||||||
|
|
||||||
// Accounts
|
|
||||||
;[publisher, consumer] = await ocean.accounts.list()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should regiester an asset', async () => {
|
it('should regiester an asset', async () => {
|
||||||
@ -45,7 +50,12 @@ xdescribe('Consume Asset (Large size)', () => {
|
|||||||
it('should order the asset', async () => {
|
it('should order the asset', async () => {
|
||||||
const accessService = ddo.findServiceByType('Access')
|
const accessService = ddo.findServiceByType('Access')
|
||||||
|
|
||||||
await consumer.requestTokens(metadata.base.price)
|
try {
|
||||||
|
await consumer.requestTokens(
|
||||||
|
+metadata.base.price *
|
||||||
|
10 ** -(await ocean.keeper.token.decimals())
|
||||||
|
)
|
||||||
|
} catch {}
|
||||||
|
|
||||||
agreementId = await ocean.assets.order(
|
agreementId = await ocean.assets.order(
|
||||||
ddo.id,
|
ddo.id,
|
||||||
|
@ -18,7 +18,7 @@ describe('Register Escrow Access Secret Store Template', () => {
|
|||||||
|
|
||||||
const url = 'https://example.com/did/ocean/test-attr-example.txt'
|
const url = 'https://example.com/did/ocean/test-attr-example.txt'
|
||||||
const checksum = 'b'.repeat(32)
|
const checksum = 'b'.repeat(32)
|
||||||
const escrowAmount = 12
|
let escrowAmount = 12
|
||||||
|
|
||||||
let templateManagerOwner: Account
|
let templateManagerOwner: Account
|
||||||
let publisher: Account
|
let publisher: Account
|
||||||
@ -44,6 +44,10 @@ describe('Register Escrow Access Secret Store Template', () => {
|
|||||||
keeper.conditions.accessSecretStoreCondition
|
keeper.conditions.accessSecretStoreCondition
|
||||||
lockRewardCondition = keeper.conditions.lockRewardCondition
|
lockRewardCondition = keeper.conditions.lockRewardCondition
|
||||||
escrowReward = keeper.conditions.escrowReward
|
escrowReward = keeper.conditions.escrowReward
|
||||||
|
|
||||||
|
if (!ocean.keeper.dispenser) {
|
||||||
|
escrowAmount = 0
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Propose and approve template', () => {
|
describe('Propose and approve template', () => {
|
||||||
@ -169,7 +173,9 @@ describe('Register Escrow Access Secret Store Template', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should fulfill LockRewardCondition', async () => {
|
it('should fulfill LockRewardCondition', async () => {
|
||||||
|
try {
|
||||||
await consumer.requestTokens(escrowAmount)
|
await consumer.requestTokens(escrowAmount)
|
||||||
|
} catch {}
|
||||||
|
|
||||||
await keeper.token.approve(
|
await keeper.token.approve(
|
||||||
lockRewardCondition.getAddress(),
|
lockRewardCondition.getAddress(),
|
||||||
@ -259,7 +265,9 @@ describe('Register Escrow Access Secret Store Template', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should fulfill the conditions from consumer side', async () => {
|
it('should fulfill the conditions from consumer side', async () => {
|
||||||
|
try {
|
||||||
await consumer.requestTokens(escrowAmount)
|
await consumer.requestTokens(escrowAmount)
|
||||||
|
} catch {}
|
||||||
|
|
||||||
await ocean.agreements.conditions.lockReward(
|
await ocean.agreements.conditions.lockReward(
|
||||||
agreementId,
|
agreementId,
|
||||||
|
@ -14,8 +14,9 @@ describe('Search Asset', () => {
|
|||||||
const testHash = Math.random()
|
const testHash = Math.random()
|
||||||
.toString(36)
|
.toString(36)
|
||||||
.substr(2)
|
.substr(2)
|
||||||
|
let price
|
||||||
const metadataGenerator = (name: string) =>
|
const metadataGenerator = (name: string) =>
|
||||||
generateMetadata(`${name}${testHash}`)
|
generateMetadata(`${name}${testHash}`, price)
|
||||||
|
|
||||||
let test1length
|
let test1length
|
||||||
let test2length
|
let test2length
|
||||||
@ -38,6 +39,10 @@ describe('Search Asset', () => {
|
|||||||
.length
|
.length
|
||||||
test3length = (await ocean.assets.search(`Test3${testHash}`)).results
|
test3length = (await ocean.assets.search(`Test3${testHash}`)).results
|
||||||
.length
|
.length
|
||||||
|
|
||||||
|
if (!ocean.keeper.dispenser) {
|
||||||
|
price = 0
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should regiester some a asset', async () => {
|
it('should regiester some a asset', async () => {
|
||||||
|
@ -44,12 +44,17 @@ const metadata: Partial<MetaData> = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const generateMetadata = (name: string): Partial<MetaData> => ({
|
export const generateMetadata = (
|
||||||
|
name: string,
|
||||||
|
price?: number
|
||||||
|
): Partial<MetaData> => ({
|
||||||
...metadata,
|
...metadata,
|
||||||
base: {
|
base: {
|
||||||
...metadata.base,
|
...metadata.base,
|
||||||
name
|
name,
|
||||||
|
price: (price || 21) + '0'.repeat(18)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
export const getMetadata = () => generateMetadata('TestAsset')
|
export const getMetadata = (price?: number) =>
|
||||||
|
generateMetadata('TestAsset', price)
|
||||||
|
@ -172,4 +172,8 @@ export class EscrowAccessSecretStoreTemplate extends AgreementTemplate {
|
|||||||
escrowRewardId
|
escrowRewardId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getAgreementData(agreementId: string) {
|
||||||
|
return this.call<any>('getAgreementData', [zeroX(agreementId)])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user