-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
baafd2a
commit 3a2a32d
Showing
3 changed files
with
170 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import assert from 'assert' | ||
import { NautilusAsset } from '../../src/nautilus/asset/asset' | ||
import { | ||
datasetMetadata, | ||
datasetService, | ||
fixedPricing | ||
} from '../fixtures/AssetConfig' | ||
import { freParams } from '../fixtures/FixedRateExchangeParams' | ||
import { getWeb3 } from '../fixtures/Web3' | ||
|
||
describe('NautilusAsset', () => { | ||
const web3 = getWeb3() | ||
const owner = web3.defaultAccount | ||
|
||
it('configures owner correctly', () => { | ||
const asset = new NautilusAsset() | ||
asset.metadata = datasetMetadata | ||
asset.services.push(datasetService) | ||
asset.pricing = { ...fixedPricing, freCreationParams: freParams as any } | ||
asset.owner = owner | ||
|
||
const config = asset.getConfig() | ||
|
||
assert.equal( | ||
config.tokenParamaters.datatokenParams.paymentCollector, | ||
owner, | ||
'datatokenParams.paymentCollector != owner' | ||
) | ||
assert.equal( | ||
config.tokenParamaters.datatokenParams.minter, | ||
owner, | ||
'datatokenParams.minter != owner' | ||
) | ||
assert.equal( | ||
config.tokenParamaters.nftParams.owner, | ||
owner, | ||
'nftParams.owner != owner' | ||
) | ||
assert.equal( | ||
config.pricing.freCreationParams.owner, | ||
owner, | ||
'nftParams.owner != owner' | ||
) | ||
}) | ||
}) |
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,125 @@ | ||
import { ZERO_ADDRESS } from '@oceanprotocol/lib' | ||
import assert from 'assert' | ||
import { AssetBuilder } from '../../src' | ||
import { | ||
algorithmMetadata, | ||
datasetService, | ||
fixedPricing | ||
} from '../fixtures/AssetConfig' | ||
import { datatokenParams } from '../fixtures/DatatokenParams' | ||
import { nftParams } from '../fixtures/NftCreateData' | ||
|
||
describe('AssetBuilder', () => { | ||
it('builds asset.metadata correctly', async () => { | ||
const builder = new AssetBuilder() | ||
|
||
const { type, name, author, description, license, algorithm } = | ||
algorithmMetadata | ||
|
||
const asset = builder | ||
.setType(type) | ||
.setName(name) | ||
.setAuthor(author) | ||
.setDescription(description) | ||
.setLicense(license) | ||
.setAlgorithm(algorithm) | ||
.build() | ||
|
||
assert.deepEqual( | ||
asset.metadata, | ||
algorithmMetadata, | ||
`asset.metadata does not equal the given input metadata` | ||
) | ||
}) | ||
|
||
it('builds asset.pricing correctly', async () => { | ||
const builder = new AssetBuilder() | ||
|
||
const asset = builder.setPricing(fixedPricing).build() | ||
|
||
assert.deepEqual( | ||
asset.pricing, | ||
fixedPricing, | ||
`asset.pricing does not equal the given input pricing schema` | ||
) | ||
}) | ||
|
||
it('builds asset.services correctly', async () => { | ||
const builder = new AssetBuilder() | ||
|
||
const asset = builder.addService(datasetService).build() | ||
|
||
assert.ok( | ||
asset.services.includes(datasetService), | ||
`asset.services does not contain the given input service` | ||
) | ||
}) | ||
|
||
it('builds asset.datatokenCreateParams correctly', async () => { | ||
const builder = new AssetBuilder() | ||
|
||
const { name, symbol, ...params } = datatokenParams | ||
|
||
const asset = builder | ||
.setDatatokenData(params) | ||
.setDatatokenNameAndSymbol(name, symbol) | ||
.build() | ||
|
||
assert.deepEqual( | ||
asset.datatokenCreateParams, | ||
datatokenParams, | ||
`asset.datatokenCreateParams does not equal the given input datatokenParams` | ||
) | ||
}) | ||
|
||
it('builds asset.nftCreateData correctly', async () => { | ||
const builder = new AssetBuilder() | ||
|
||
const asset = builder.setNftData(nftParams).build() | ||
|
||
assert.deepEqual( | ||
asset.nftCreateData, | ||
nftParams, | ||
`asset.nftCreateData does not equal the given input nftParams` | ||
) | ||
}) | ||
|
||
it('builds asset.owner correctly', async () => { | ||
const builder = new AssetBuilder() | ||
|
||
const owner = 'owner' | ||
|
||
const asset = builder.setOwner(owner).build() | ||
|
||
assert.equal( | ||
asset.owner, | ||
owner, | ||
'asset.owner does not match the given input owner' | ||
) | ||
}) | ||
|
||
it('builds with default values', async () => { | ||
const builder = new AssetBuilder() | ||
|
||
const asset = builder.build() | ||
|
||
const { nftCreateData, datatokenCreateParams } = asset | ||
|
||
// Default NftCreateData | ||
assert.ok(typeof nftCreateData.name === 'string') | ||
assert.ok(typeof nftCreateData.symbol === 'string') | ||
assert.ok(typeof nftCreateData.templateIndex === 'number') | ||
assert.ok(typeof nftCreateData.tokenURI === 'string') | ||
assert.ok(typeof nftCreateData.transferable === 'boolean') | ||
|
||
// Default DatatokenCreateParams | ||
assert.ok(typeof datatokenCreateParams.cap === 'string') | ||
assert.ok(typeof datatokenCreateParams.feeAmount === 'string') | ||
assert.ok(datatokenCreateParams.feeToken === ZERO_ADDRESS) | ||
assert.ok(datatokenCreateParams.mpFeeAddress === ZERO_ADDRESS) | ||
assert.ok(typeof datatokenCreateParams.templateIndex === 'number') | ||
// Datatoken name and symbol are undefined by default | ||
assert.ok(typeof datatokenCreateParams.name === 'undefined') | ||
assert.ok(typeof datatokenCreateParams.symbol === 'undefined') | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.