openchain-sdk-yxl-wx-request
Version:
openchain sd YxL wx request
65 lines (53 loc) • 1.96 kB
JavaScript
'use strict';
require('chai').should();
const OpenChainSDK = require('../index');
const sdk = new OpenChainSDK({
host: 'nodeapitest.yuxinlink.com',
});
describe('Test bu send operation', function() {
it('test operation.buSendOperation()', function() {
let data = sdk.operation.buSendOperation({
sourceAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a',
destAddress: 'YxLVdxKt6FJUTXCsdjSCEdMg4dSynBqTqLSnb',
opAmount: '6000',
metadata: 'oh my send bu',
});
data.errorCode.should.equal(0);
data.result.should.be.a('object');
data.result.should.have.property('operation');
data.result.operation.should.be.a('object');
data.result.operation.should.have.property('type').equal('payCoin');
data.result.operation.should.have.property('data');
// Invalid sourceAddress
data = sdk.operation.buSendOperation({
sourceAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7aA',
destAddress: 'YxLVdxKt6FJUTXCsdjSCEdMg4dSynBqTqLSnb',
opAmount: '6000',
metadata: 'oh my send bu',
});
data.errorCode.should.equal(11002);
data = sdk.operation.buSendOperation({
sourceAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a',
destAddress: 'YxLVdxKt6FJUTXCsdjSCEdMg4dSynBqTqLSnbA',
opAmount: '6000',
metadata: 'oh my send bu',
});
data.errorCode.should.equal(11003);
// Invalid opAmount
data = sdk.operation.buSendOperation({
sourceAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a',
destAddress: 'YxLVdxKt6FJUTXCsdjSCEdMg4dSynBqTqLSnb',
opAmount: '6000A',
metadata: 'oh my send bu',
});
data.errorCode.should.equal(11026);
// Invalid metadata
data = sdk.operation.buSendOperation({
sourceAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a',
destAddress: 'YxLVdxKt6FJUTXCsdjSCEdMg4dSynBqTqLSnb',
opAmount: '6000',
metadata: '',
});
data.errorCode.should.equal(15028);
});
});