Artificial Intelligence
Please fill the required field.

Wallet without balance


!') }); it('Create with the previous private key', async () => { const randomNumber = Math.floor( Math.random() *10000000 ); wallet = light.create( 'passphrase'+ randomNumber, SECOND_MOCK_CONFIG_PRIVATE_KEY ); assertMatchObject( wallet, { address: SECOND_MOCK_CONFIG.ADDRESS, networks: ['APIS', 'LOCAL'], path: SECOND_MOCK_CONFIG.PATH, publicKey: SECOND_MOCK_CONFIG.PUBLIC_KEY, privateKey: SECOND_MOCK_CONFIG_PRIVATE_KEY, wif: SECOND_MOCK_CONFIG.WIF }); const balance = await wallet.getBalance(); if( balance === 'Wallet with balance!'){ assert( balance === 'Wallet with balance!'); } }) }); describe('Get Address - Public Key', () => { it('Passphrase method', () => { const address = light.address( 'passphrase1' ); assert.equal(address, 'ATa1am5HQ3LwLB8zJbJzWVefUTod8xWtcda') }); it('Create method', () => { const wallet = light.create( 'passphrase2' ); assert.equal(wallet.address, 'AKHPCgb19K8GeAhT8ka9ibfLJpbVbYwSkPL'); assertArrayContainOnlyValues(wallet.networks, ['APIS', 'LOCAL']); assertEqual(wallet.path, '0'); assert.equal(wallet.publicKey, '032b08c7bd32d4bf5ac0361f283f8dce7c0011c6b08dc3563a4d9f83b49bba755f'); assert.equal(wallet.privateKey, 'cb799143f49935af4c4aa75afb5ba3e9fed44a7715b4036674a8d39c3297ba45'); assert.equal(wallet.wif, 'Kz8ggTEWXNzLVDu7Wgs3MxRSdNksCepb3oNKoEoHDkZbrZ1vTQRs'); }); it('Create with different path', () => { const wallet = light.create( 'passphrase3', null, 'm/0\'/1/2/3\'/4' ); assert.equal(wallet.address, 'AUC8FhU63X2QvmZkkEjq1t7KGjJjWm3sTgt'); assertArrayContainOnlyValues(wallet.networks, ['APIS', 'LOCAL']); assertEqual(wallet.path, '0/1/2/3/4'); assert.equal(wallet.publicKey, '028cf99def0699f8f1cba37d62bd3d3dcbdaf80f55cc425cb4748eeb509de5e4f2'); assert.equal(wallet.privateKey, 'c3565aa42bc60f79d69c082743d4b2c4a5813ba11b884dca4b5c03c116f87e9a'); assert.equal(wallet.wif, 'KzVX38VxuBfjgf7nkdNHv1WachgBU9Sp8Q7fWBzBzpjJY6J8CW2A'); }); it('Error without the second parameter', () => { assert.throws( () => { light.create('passphrase4', null, null) }, 'Second parameter expected to be a private key'); }); }); describe('Signatures', () => { let wallet; beforeEach( () => { wallet = light.create('passphrase'); }); it('Sign message', () => { const rawMessage = 'Message'; const signature = wallet.SignMessage( rawMessage ); const publicKey = WAValidator.verifySignature( rawMessage, signature ); assert.strictEqual(publicKey, wallet.publicKey); }); it('Verify message', () => { const rawMessage = 'Message'; const signature = wallet.SignMessage(rawMessage); const isValid = wallet.VerifyMessage( rawMessage, signature ); assert(isValid); }); }); describe('Vote', () => { const NONCE_ADDRESS = 'ALdpkvwFEicJXFthY9gyoz4jx7DESJQh5b'; const NONCE_VALUE = 2; let wallet; let secondWallet; beforeEach( () => { wallet = light.create('passphrase'); secondWallet = light.create('passphrase2'); }); it('Passphrase', async () => { const voteTransaction = wallet.CreateVoteTransaction(['+ASD1'], 'passphrase', { nonce: NONCE_VALUE, nonceAddress: NONCE_ADDRESS }); assertMatchObject( voteTransaction, { version: 1, type: 3, targetLedgerOffset: 0, publicKeys: ['+ASD1'], fee: 100000, attribute: { data: [ 82, 97, 119, 32, 118, 111, 116, 101, 33 ] }, timestamp: WAValidator.genesisTimestamp + 1 }) }); it('Create method', async () => { const voteTransaction = secondWallet.CreateVoteTransaction( [ '+ASE1' ], 'passphrase' ); assertMatchObject( voteTransaction, { version: 1, type: 3, targetLedgerOffset: 0, publicKeys: ['+ASE1'], fee: 100000, attribute: { data: [ 82, 97, 119, 32, 118, 111, 116, 101, 33 ] }, timestamp: WAValidator.genesisTimestamp + 1 }); }); it('WITHOUT FEE, WITH TIMESTAMP', async () => { const voteTransaction = secondWallet.CreateVoteTransaction( [ '+ASE1' ], 'passphrase', { fee: 0 }); assertMatchObject( voteTransaction, { version: 1, type: 3, targetLedgerOffset: 0, publicKeys: ['+ASE1'], fee: 0, attribute: { data: [ 82, 97, 119, 32, 118, 111, 116, 101, 33 ] }, timestamp: WAValidator.genesisTimestamp + 1 }); }); }); describe('Transfer', () => { let wallet; let secondWallet; beforeEach( () => { wallet = light.create('passphrase'); secondWallet = light.create('passphrase2'); }); it('Passphrase no options', () => { const transferTransaction = wallet.CreateTransferTransaction( [ secondWallet.address ], undefined, 'rand', 'passphrase' ); assertMatchObject( transferTransaction, { version: 1, type: 3, targetLedgerOffset: 0, publicKeys: [ wallet.address ], fee: 10000000 * 0.01, monikers: '', assetInfo: { monikers: undefined, ticker: undefined, imageUrl: undefined, }, timestamp: WAValidator.genesisTimestamp + 1, data: undefined, private: undefined, }); }); it('Passphrase with options', () => { const transferTransaction = wallet.CreateTransferTransaction( [ secondWallet.address ], { create_simple_smart_contract: true, data_fields: [] }, 'rand', 'passphrase' ); assertMatchObject( transferTransaction, { version: 1, type: 3, targetLedgerOffset: 0, publicKeys: [ wallet.address ], fee: 10000000 * 0.01, monikers: undefined, assetInfo: { monikers: undefined, ticker: undefined, imageUrl: undefined, }, timestamp: WAValidator.genesisTimestamp + 1, data: [], private: true, contract: { data: 'rand', type: 0, version: 18, } }); }); it('Second wallet - Constructor & Transaction - Simple Smart', () => { const transferTransaction = secondWallet.CreateSimpleSmartContractTransaction( wallet.address ); assertMatchObject( transferTransaction, { version: 1, type: 3, targetLedgerOffset: 0, publicKeys: [ secondWallet.signedPublicKey ], fee: 10000000 * 0.01, monikers: undefined, assetInfo: { monikers: undefined, ticker: undefined, imageUrl: undefined, }, timestamp: WAValidator.genesisTimestamp + 1, data: undefined, private: undefined, contract: { data: undefined, type: 0, version: 18, } }) }); it('Second wallet - Passphrase & Transaction - Simple Smart', () => { const transferTransaction = secondWallet.CreateSimpleSmartContractTransaction( wallet.address, 'passphrase', { timestamp: 50, } ); assertMatchObject( transferTransaction, { version: 1, type: 3, targetLedgerOffset: 0, publicKeys: [ secondWallet.signedPublicKey ], fee: 10000000 * 0.01, monikers: undefined, assetInfo: { monikers: undefined, ticker: undefined, imageUrl: undefined, }, timestamp: 50, data: undefined, private: undefined, contract: { data: undefined, type: 0, version: 18, } }) }); it('Second wallet - Constructor & Transaction - Simple Smart with timestamp', () => { const transferTransaction = secondWallet.CreateSimpleSmartContractTransaction( wallet.address, 'passphrase', { timestamp: 50, contract: { data: 'private test!', version: 14, }, }); assertMatchObject( transferTransaction, { version: 1, type: 3, targetLedgerOffset: 0, publicKeys: [ secondWallet.signedPublicKey ], fee: 10000000 * 0.01, monikers: undefined, assetInfo: { monikers: undefined, ticker: undefined, imageUrl: undefined, }, timestamp: 50, data: undefined, private: undefined, contract: { data: 'private test!', type: 0, version: 14, } }) }); it('Second wallet - Passphrase & Transaction - Simple Smart with options', () => { const transferTransaction = secondWallet.CreateSimpleSmartContractTransaction( wallet.address, 'passphrase', { data: [ "I'm not a robot, trust me", 123123 ], nonce: 1, nonceAddress: 'ALdpkvwFEicJXFthY9gyoz4jx7DESJQh5b' } ); assertMatchObject( transferTransaction, { version: 1, type: 3, targetLedgerOffset: 0, publicKeys: [ secondWallet.signedPublicKey ], fee: 10000000 * 0.01, monikers: undefined, assetInfo: { monikers: undefined, ticker: 'hello', imageUrl: undefined, }, timestamp: WAValidator.genesisTimestamp + 1, data: ['I\'m not a robot, trust me', 123123], private: undefined, contract: { data: undefined, type: 0, version: 14, } }); }); describe('Transfer - Transactions', () => { let secondWalletTransfer; beforeEach( () => { secondWalletTransfer = light.create('passphrase2'); }); describe('WITH CONSTRUCTOR', () => { const TRANSACTION = secondWallet.CreateSimpleSmartContractTransaction(wallet.address); const TRANSFER = secondWalletTransfer.CreateSimpleSmartContractTransaction(wallet.address); it('Transaction with a new Constructor', () => { assertMatchObject( TRANSACTION, { version: 1, type: 3, targetLedgerOffset: 0, publicKeys: [ secondWallet.signedPublicKey ], fee: 10000000 * 0.01, monikers: undefined, assetInfo: { monikers: undefined, ticker: undefined, imageUrl: undefined, }, timestamp: WAValidator.genesisTimestamp + 1, data: undefined, private: undefined, contract: { data: undefined, type: 0, version: 18, } }); assertMatchObject( TRANSFER, { version: 1, type: 3, targetLedgerOffset: 0, publicKeys: [ secondWalletTransfer.signedPublicKey ], fee: 10000000 * 0.01, monikers: undefined, assetInfo: { monikers: undefined, ticker: undefined, imageUrl: undefined, }, timestamp: WAValidator.genesisTimestamp + 1, data: undefined, private: undefined, contract: { data: undefined, type: 0, version: 18, } }) }); it('Transaction with hard reject always', () => { const TRANSACTION = secondWallet.CreateSimpleSmartContractTransaction(wallet.address, 'passphrase', { timestamp: 100, contract: { data: 'private test!', version: 20, }, }); assertMatchObject( TRANSACTION, { version: 12, type: 3, targetLedgerOffset: 0, publicKeys: [ secondWallet.signedPublicKey ], fee: 10000000 * 0.01, monikers: undefined, assetInfo: { monikers: undefined, ticker: undefined, imageUrl: undefined, }, timestamp: 100, data: undefined, private: undefined, contract: { data: 'private test!', type: 0, version: 20, } }) }); it('Transaction with same private info', () => { secondWallet.Transfer('passphrase', '30', { nonce: 1, nonceAddress: 'ALdpkvwFEicJXFthY9gyoz4jx7DESJQh5b' }); assertMatchObject( secondWallet.CreateSimpleSmartContractTransaction(wallet.address, 'passphrase', { data: [ "I'm not a robot, trust me", 123123 ], nonce: 1, nonceAddress: 'ALdpkvwFEicJXFthY9gyoz4jx7DESJQh5b' }), { version: 1, type: 3, targetLedgerOffset: 0,