colu-access
Version:
Colu access app for registering a user, issue an access token and verify his holding in login.
118 lines (111 loc) • 3.27 kB
JavaScript
var ColuAccess = require(__dirname + '/../src/coluaccess.js')
var assert = require('assert')
var expect = require('chai').expect
describe('Test Colu SDK', function () {
var settings = {
network: 'testnet',
coluHost: 'https://dev.engine.colu.co'
}
var privateSeed
var toAddress = 'mgNcWJp4hPd7MN6ets2P8HcB5k99aCs8cy'
var assetId
var fromAddress
var phoneNumber = '+1234567890'
it('Should create and broadcast issue tx.', function (done) {
this.timeout(120000)
var coluAccess = new ColuAccess(settings)
var colu = coluAccess.colu
colu.on('connect', function () {
privateSeed = colu.hdwallet.getPrivateSeed()
var args = {
amount: 2,
divisibility: 0,
fee: 1000,
reissueable: false,
transfer: [
{
amount: 1
}
]
}
colu.issueAsset(args, function (err, ans) {
if (err) console.error(err)
assert(!err)
expect(ans.txHex).to.be.a('string')
expect(ans.txHex).to.have.length.above(0)
expect(ans.assetId).to.be.a('string')
expect(ans.assetId).to.have.length.above(0)
assetId = ans.assetId
expect(ans.txid).to.be.a('string')
expect(ans.txid).to.have.length.above(0)
expect(ans.issueAddress).to.be.a('string')
expect(ans.issueAddress).to.have.length.above(0)
expect(ans.receivingAddresses).to.be.a('array')
expect(ans.receivingAddresses).to.have.length.above(0)
fromAddress = ans.receivingAddresses[0].address
done()
})
})
colu.init()
})
it('Should create and broadcast send tx.', function (done) {
this.timeout(120000)
settings.privateSeed = privateSeed
var coluAccess = new ColuAccess(settings)
var colu = coluAccess.colu
colu.on('connect', function () {
var address = fromAddress
var args = {
from: [address],
fee: 1000,
to: [
{
address: toAddress,
assetId: assetId,
amount: 1
}
]
}
colu.sendAsset(args, function (err, ans) {
if (err) console.error(err)
assert(!err)
expect(ans.txHex).to.be.a('string')
expect(ans.txHex).to.have.length.above(0)
expect(ans.txid).to.be.a('string')
expect(ans.txid).to.have.length.above(0)
done()
})
})
colu.init()
})
it('Should create and broadcast send tx to phone.', function (done) {
this.timeout(120000)
settings.privateSeed = privateSeed
var coluAccess = new ColuAccess(settings)
var colu = coluAccess.colu
colu.on('connect', function () {
var address = fromAddress
var args = {
from: [address],
fee: 1000,
to: [
{
phoneNumber: phoneNumber,
assetId: assetId,
amount: 1
}
]
}
colu.sendAsset(args, function (err, ans) {
if (err) console.error(err)
assert(!err)
expect(ans.txHex).to.be.a('string')
expect(ans.txHex).to.have.length.above(0)
expect(ans.txid).to.be.a('string')
expect(ans.txid).to.have.length.above(0)
done()
})
})
colu.init()
})
})