mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
test tweaks
This commit is contained in:
parent
c772324b34
commit
354149d2d4
@ -26,7 +26,7 @@ before_script:
|
||||
- export KEEPER_VERSION=v0.12.6
|
||||
- export EVENTS_HANDLER_VERSION=v0.1.2
|
||||
- export KEEPER_OWNER_ROLE_ADDRESS="0xe2DD09d719Da89e5a3D0F2549c7E24566e947260"
|
||||
- bash -x start_ocean.sh --no-commons --local-spree-node 2>&1 > start_ocean.log &
|
||||
- bash -x start_ocean.sh --no-commons --no-dashboard 2>&1 > start_ocean.log &
|
||||
- cd ..
|
||||
|
||||
script:
|
||||
|
@ -1,9 +1,6 @@
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { config } from '../config'
|
||||
|
||||
import { getMetadata } from '../utils'
|
||||
|
||||
import { Ocean, Account } from '../../src' // @oceanprotocol/squid
|
||||
|
||||
describe('Asset Owners', () => {
|
||||
@ -25,15 +22,14 @@ describe('Asset Owners', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('should be set correctly the owner of an asset', async () => {
|
||||
it('should set the owner of an asset', async () => {
|
||||
const ddo = await ocean.assets.create(metadata as any, account1)
|
||||
|
||||
const owner = await ocean.assets.owner(ddo.id)
|
||||
|
||||
assert.equal(owner, account1.getId())
|
||||
})
|
||||
|
||||
it('should be set correctly the provider of an asset', async () => {
|
||||
it('should set the provider of an asset', async () => {
|
||||
const ddo = await ocean.assets.create(metadata as any, account1)
|
||||
|
||||
const isProvider = await ocean.keeper.didRegistry.isDIDProvider(
|
||||
@ -61,7 +57,7 @@ describe('Asset Owners', () => {
|
||||
assert.equal(finalLength - initialLength, 1)
|
||||
})
|
||||
|
||||
it('should get the assets that can be consumer by a user', async () => {
|
||||
it('should get the assets that can be consumed by a user', async () => {
|
||||
const { length: initialLength } = await ocean.assets.consumerAssets(
|
||||
account2.getId()
|
||||
)
|
||||
|
@ -20,7 +20,7 @@ export class ContractEvent {
|
||||
public subscribe(
|
||||
callback: (events: any[]) => void
|
||||
): ContractEventSubscription {
|
||||
const onEvent = async blockNumber => {
|
||||
const onEvent = async (blockNumber: number) => {
|
||||
const events = await this.contract.getEventData(this.eventName, {
|
||||
filter: this.filter,
|
||||
fromBlock: blockNumber,
|
||||
|
@ -5,7 +5,7 @@ LoggerInstance.setLevel(LogLevel.Error)
|
||||
|
||||
export default {
|
||||
aquariusUri: 'http://localhost:5000',
|
||||
brizoUri: 'http://localhost:3000',
|
||||
brizoUri: 'http://localhost:8030',
|
||||
nodeUri: `http://localhost:${process.env.ETH_PORT || 8545}`,
|
||||
parityUri: 'http://localhost:9545',
|
||||
secretStoreUri: 'http://localhost:12001',
|
||||
|
@ -22,7 +22,7 @@ describe('ContractEvent', () => {
|
||||
})
|
||||
|
||||
describe('#subscribe()', () => {
|
||||
it('should listen the events', async () => {
|
||||
it('should be able to listen to events', async () => {
|
||||
const event = eventHandler.getEvent(
|
||||
ocean.keeper.token,
|
||||
'Transfer',
|
||||
@ -55,7 +55,7 @@ describe('ContractEvent', () => {
|
||||
})
|
||||
|
||||
describe('#once()', () => {
|
||||
it('should listen only once', async () => {
|
||||
it('should listen to event only once', async () => {
|
||||
const to = account
|
||||
const event = eventHandler.getEvent(
|
||||
ocean.keeper.token,
|
||||
@ -65,7 +65,7 @@ describe('ContractEvent', () => {
|
||||
let canBeRejected = false
|
||||
|
||||
const waitUntilEvent = new Promise((resolve, reject) => {
|
||||
event.once(events => {
|
||||
event.once(() => {
|
||||
if (canBeRejected) {
|
||||
reject(new Error(''))
|
||||
}
|
||||
|
@ -4,6 +4,11 @@ import Web3Provider from '../../src/keeper/Web3Provider'
|
||||
import Logger from '../../src/utils/Logger'
|
||||
import config from '../config'
|
||||
|
||||
interface TestContract extends Contract {
|
||||
testContract?: boolean
|
||||
$initialized?: boolean
|
||||
}
|
||||
|
||||
export default class TestContractHandler extends ContractHandler {
|
||||
public static async prepareContracts() {
|
||||
const web3 = Web3Provider.getWeb3(config)
|
||||
@ -134,20 +139,23 @@ export default class TestContractHandler extends ContractHandler {
|
||||
from: string,
|
||||
args: any[] = [],
|
||||
tokens: { [name: string]: string } = {}
|
||||
): Promise<any & { $initialized: boolean }> {
|
||||
): Promise<any> {
|
||||
const where = this.networkId
|
||||
|
||||
// dont redeploy if there is already something loaded
|
||||
if (TestContractHandler.hasContract(name, where)) {
|
||||
const contract = await ContractHandler.getContract(name, where)
|
||||
if ((contract as any).testContract) {
|
||||
const contract: TestContract = ContractHandler.getContract(
|
||||
name,
|
||||
where
|
||||
)
|
||||
if (contract.testContract) {
|
||||
return { ...contract, $initialized: true }
|
||||
}
|
||||
}
|
||||
|
||||
const web3 = Web3Provider.getWeb3(config)
|
||||
|
||||
let contractInstance: Contract
|
||||
let contractInstance: TestContract
|
||||
try {
|
||||
Logger.log('Deploying', name)
|
||||
const sendConfig = {
|
||||
@ -188,7 +196,7 @@ export default class TestContractHandler extends ContractHandler {
|
||||
.initialize(...args)
|
||||
.send(sendConfig)
|
||||
}
|
||||
;(contractInstance as any).testContract = true
|
||||
contractInstance.testContract = true
|
||||
ContractHandler.setContract(name, where, contractInstance)
|
||||
// Logger.log("Deployed", name, "at", contractInstance.options.address);
|
||||
} catch (err) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user