UNPKG

openchain-sdk-yxl-wx-request

Version:

openchain sd YxL wx request

100 lines (82 loc) 3.15 kB
'use strict'; require('chai').should(); const OpenChainSDK = require('../index'); const sdk = new OpenChainSDK({ host: 'nodeapitest.yuxinlink.com', }); describe('Test account activate operation', function() { it('test operation.accountActivateOperation()', function() { let data = sdk.operation.accountActivateOperation({ sourceAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a', destAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a', initBalance: '1000', metadata: 'Test Account Activate', }); data.should.be.a('object'); data.errorCode.should.equal(0); data.result.should.have.property('operation').be.a('object'); data.result.operation.should.have.property('type'); data.result.operation.should.have.property('data'); data.result.operation.type.should.equal('activateAccount'); // Invalid sourceAddress data = sdk.operation.accountActivateOperation({ sourceAddress: '', destAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a', initBalance: '1000', }); data.errorCode.should.equal(11002); data = sdk.operation.accountActivateOperation({ sourceAddress: null, destAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a', initBalance: '1000', }); data.errorCode.should.equal(11002); // Invalid destAddress data = sdk.operation.accountActivateOperation({ sourceAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a', destAddress: '', initBalance: '1000', }); data.errorCode.should.equal(11003); // sourceAddress === destAddress data = sdk.operation.accountActivateOperation({ sourceAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a', destAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a', initBalance: '1000', }); data.errorCode.should.equal(11005); // Invalid initBalance data = sdk.operation.accountActivateOperation({ sourceAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a', destAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a', initBalance: 1000, }); data.errorCode.should.equal(11004); data = sdk.operation.accountActivateOperation({ sourceAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a', destAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a', initBalance: '', }); data.errorCode.should.equal(11004); data = sdk.operation.accountActivateOperation({ sourceAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a', destAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a', }); data.errorCode.should.equal(11004); // Invalid metadata data = sdk.operation.accountActivateOperation({ sourceAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a', destAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a', initBalance: '1000', metadata: '', }); data.errorCode.should.equal(15028); data = sdk.operation.accountActivateOperation({ sourceAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a', destAddress: 'YxLVkMLxmJEtDQEob3SvVnZGjp7XrWSDvKm7a', initBalance: '1000', metadata: 123, }); data.errorCode.should.equal(15028); }); });