feat: expose feeCalculator

This commit is contained in:
Michael Vines
2019-06-12 14:36:05 -07:00
parent 9fde1eb404
commit 10e3a26338
7 changed files with 91 additions and 20 deletions

View File

@ -204,8 +204,12 @@ test('get recent blockhash', async () => {
mockGetRecentBlockhash();
const recentBlockhash = await connection.getRecentBlockhash();
const [
recentBlockhash,
feeCalculator,
] = await connection.getRecentBlockhash();
expect(recentBlockhash.length).toBeGreaterThanOrEqual(43);
expect(feeCalculator.lamportsPerSignature).toBeGreaterThanOrEqual(0);
});
test('request airdrop', async () => {
@ -482,7 +486,9 @@ test('multi-instruction transaction', async () => {
accountFrom.publicKey,
accountTo.publicKey,
100,
).add(SystemProgram.transfer(accountTo.publicKey, accountFrom.publicKey, 100));
).add(
SystemProgram.transfer(accountTo.publicKey, accountFrom.publicKey, 100),
);
const signature = await connection.sendTransaction(
transaction,
accountFrom,

View File

@ -18,7 +18,7 @@ export function mockGetRecentBlockhash() {
result: [
recentBlockhash.publicKey.toBase58(),
{
/* empty fee calculator */
lamportsPerSignature: 42,
},
],
},

View File

@ -137,11 +137,11 @@ test('transaction-payer', async () => {
},
]);
// accountPayer should be less less than 100 as it paid for the transaction
// accountPayer could be less than 100 as it paid for the transaction
// (exact amount less depends on the current cluster fees)
const balance = await connection.getBalance(accountPayer.publicKey);
expect(balance).toBeGreaterThan(0);
expect(balance).toBeLessThanOrEqual(99);
expect(balance).toBeLessThanOrEqual(100);
// accountFrom should have exactly 2, since it didn't pay for the transaction
mockRpc.push([