Skip to content

Commit

Permalink
Merge pull request #263 from fioprotocol/eric/xfer
Browse files Browse the repository at this point in the history
Test when sending from acct with no fio
  • Loading branch information
ericbutz authored Jun 3, 2022
2 parents ffe4cee + 0e00c75 commit f9e9588
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions tests/transfer-tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,70 @@ describe('B. Transfer Tokens to Sad account ', () => {
})
})


describe('C. Transfer tokens from account with no tokens ', () => {

let noFio, user2, newkeypair;

it(`Create users`, async () => {
newKeyPair = await createKeypair();
noFio = new FIOSDK(newKeyPair.privateKey, newKeyPair.publicKey, config.BASE_URL, fetchJson);
user2 = await newUser(faucet);
});

it(`user2 set domain public`, async () => {
try {
const result = await user2.sdk.genericAction('setFioDomainVisibility', {
fioDomain: user2.domain,
isPublic: true,
maxFee: config.maxFee,
walletFioAddress: ''
})
//console.log('Result: ', result)
expect(result.status).to.equal('OK')
} catch (err) {
console.log('Error: ', err)
}
})

it(`regaddress for noFio account to create account.`, async () => {
try {
newAddress = generateFioAddress(user2.domain, 8)
const result = await faucet.genericAction('pushTransaction', {
action: 'regaddress',
account: 'fio.address',
data: {
fio_address: newAddress,
owner_fio_public_key: newKeyPair.publicKey,
max_fee: config.maxFee,
tpid: ''
}
})
//console.log('Result: ', result)
expect(result.status).to.equal('OK')
} catch (err) {
console.log('Error: ', err)
expect(err).to.equal('null')
}
})

it(`FAILURE: Send FIO from account with no FIO. `, async () => {
try {
const result = await noFio.genericAction('pushTransaction', {
action: 'trnsfiopubky',
account: 'fio.token',
data: {
payee_public_key: user2.publicKey,
amount: 10000000000,
max_fee: config.maxFee,
tpid: ''
}
})
//console.log('Result: ', result)
expect(result.status).to.not.equal('OK')
} catch (err) {
//console.log('Error: ', err.json)
expect(err.json.fields[0].error).to.equal('Insufficient balance')
}
})
});

0 comments on commit f9e9588

Please sign in to comment.