fix: make sol-to-lamport const name more clear

This commit is contained in:
Tyera Eulberg
2019-12-30 11:36:12 -07:00
committed by Michael Vines
parent eef794d9be
commit b2243802b5
4 changed files with 17 additions and 17 deletions

View File

@ -369,5 +369,5 @@ declare module '@solana/web3.js' {
// === src/util/testnet.js === // === src/util/testnet.js ===
declare export function testnetChannelEndpoint(channel?: string): string; declare export function testnetChannelEndpoint(channel?: string): string;
declare export var SOL_LAMPORTS: number; declare export var LAMPORTS_PER_SOL: number;
} }

View File

@ -20,4 +20,4 @@ export {
export {testnetChannelEndpoint} from './util/testnet'; export {testnetChannelEndpoint} from './util/testnet';
// There are 2^34 lamports in one SOL // There are 2^34 lamports in one SOL
export const SOL_LAMPORTS = 17179869184; export const LAMPORTS_PER_SOL = 17179869184;

View File

@ -4,7 +4,7 @@ import {
Connection, Connection,
SystemProgram, SystemProgram,
sendAndConfirmTransaction, sendAndConfirmTransaction,
SOL_LAMPORTS, LAMPORTS_PER_SOL,
} from '../src'; } from '../src';
import {DEFAULT_TICKS_PER_SLOT, NUM_TICKS_PER_SECOND} from '../src/timing'; import {DEFAULT_TICKS_PER_SLOT, NUM_TICKS_PER_SECOND} from '../src/timing';
import {mockRpc, mockRpcEnabled} from './__mocks__/node-fetch'; import {mockRpc, mockRpcEnabled} from './__mocks__/node-fetch';
@ -53,8 +53,8 @@ test('get program accounts', async () => {
const account0 = new Account(); const account0 = new Account();
const account1 = new Account(); const account1 = new Account();
const programId = new Account(); const programId = new Account();
await connection.requestAirdrop(account0.publicKey, SOL_LAMPORTS); await connection.requestAirdrop(account0.publicKey, LAMPORTS_PER_SOL);
await connection.requestAirdrop(account1.publicKey, 0.5 * SOL_LAMPORTS); await connection.requestAirdrop(account1.publicKey, 0.5 * LAMPORTS_PER_SOL);
let transaction = SystemProgram.assign( let transaction = SystemProgram.assign(
account0.publicKey, account0.publicKey,
@ -79,11 +79,11 @@ test('get program accounts', async () => {
]).toEqual(expect.arrayContaining([element[0]])); ]).toEqual(expect.arrayContaining([element[0]]));
if (element[0] == account0.publicKey) { if (element[0] == account0.publicKey) {
expect(element[1].lamports).toBe( expect(element[1].lamports).toBe(
SOL_LAMPORTS - feeCalculator.lamportsPerSignature, LAMPORTS_PER_SOL - feeCalculator.lamportsPerSignature,
); );
} else { } else {
expect(element[1].lamports).toBe( expect(element[1].lamports).toBe(
0.5 * SOL_LAMPORTS - feeCalculator.lamportsPerSignature, 0.5 * LAMPORTS_PER_SOL - feeCalculator.lamportsPerSignature,
); );
} }
}); });
@ -784,8 +784,8 @@ test('multi-instruction transaction', async () => {
const accountTo = new Account(); const accountTo = new Account();
const connection = new Connection(url, 'recent'); const connection = new Connection(url, 'recent');
await connection.requestAirdrop(accountFrom.publicKey, SOL_LAMPORTS); await connection.requestAirdrop(accountFrom.publicKey, LAMPORTS_PER_SOL);
expect(await connection.getBalance(accountFrom.publicKey)).toBe(SOL_LAMPORTS); expect(await connection.getBalance(accountFrom.publicKey)).toBe(LAMPORTS_PER_SOL);
await connection.requestAirdrop(accountTo.publicKey, 21); await connection.requestAirdrop(accountTo.publicKey, 21);
expect(await connection.getBalance(accountTo.publicKey)).toBe(21); expect(await connection.getBalance(accountTo.publicKey)).toBe(21);
@ -818,11 +818,11 @@ test('multi-instruction transaction', async () => {
Ok: null, Ok: null,
}); });
// accountFrom may have less than SOL_LAMPORTS due to transaction fees // accountFrom may have less than LAMPORTS_PER_SOL due to transaction fees
expect(await connection.getBalance(accountFrom.publicKey)).toBeGreaterThan(0); expect(await connection.getBalance(accountFrom.publicKey)).toBeGreaterThan(0);
expect( expect(
await connection.getBalance(accountFrom.publicKey), await connection.getBalance(accountFrom.publicKey),
).toBeLessThanOrEqual(SOL_LAMPORTS); ).toBeLessThanOrEqual(LAMPORTS_PER_SOL);
expect(await connection.getBalance(accountTo.publicKey)).toBe(21); expect(await connection.getBalance(accountTo.publicKey)).toBe(21);
}); });
@ -849,7 +849,7 @@ test('account change notification', async () => {
1, 1,
); );
await connection.requestAirdrop(owner.publicKey, SOL_LAMPORTS); await connection.requestAirdrop(owner.publicKey, LAMPORTS_PER_SOL);
try { try {
let transaction = SystemProgram.transfer( let transaction = SystemProgram.transfer(
owner.publicKey, owner.publicKey,
@ -913,7 +913,7 @@ test('program account change notification', async () => {
}, },
); );
await connection.requestAirdrop(owner.publicKey, SOL_LAMPORTS); await connection.requestAirdrop(owner.publicKey, LAMPORTS_PER_SOL);
try { try {
let transaction = SystemProgram.transfer( let transaction = SystemProgram.transfer(
owner.publicKey, owner.publicKey,

View File

@ -1,5 +1,5 @@
// @flow // @flow
import {Account, Connection, SystemProgram, SOL_LAMPORTS} from '../src'; import {Account, Connection, SystemProgram, LAMPORTS_PER_SOL} from '../src';
import {mockRpc, mockRpcEnabled} from './__mocks__/node-fetch'; import {mockRpc, mockRpcEnabled} from './__mocks__/node-fetch';
import {mockGetRecentBlockhash} from './mockrpc/get-recent-blockhash'; import {mockGetRecentBlockhash} from './mockrpc/get-recent-blockhash';
import {url} from './url'; import {url} from './url';
@ -22,7 +22,7 @@ test('transaction-payer', async () => {
method: 'requestAirdrop', method: 'requestAirdrop',
params: [ params: [
accountPayer.publicKey.toBase58(), accountPayer.publicKey.toBase58(),
SOL_LAMPORTS, LAMPORTS_PER_SOL,
{commitment: 'recent'}, {commitment: 'recent'},
], ],
}, },
@ -32,7 +32,7 @@ test('transaction-payer', async () => {
'0WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk', '0WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk',
}, },
]); ]);
await connection.requestAirdrop(accountPayer.publicKey, SOL_LAMPORTS); await connection.requestAirdrop(accountPayer.publicKey, LAMPORTS_PER_SOL);
mockRpc.push([ mockRpc.push([
url, url,
@ -147,7 +147,7 @@ test('transaction-payer', async () => {
// (exact amount less depends on the current cluster fees) // (exact amount less depends on the current cluster fees)
const balance = await connection.getBalance(accountPayer.publicKey); const balance = await connection.getBalance(accountPayer.publicKey);
expect(balance).toBeGreaterThan(0); expect(balance).toBeGreaterThan(0);
expect(balance).toBeLessThanOrEqual(SOL_LAMPORTS); expect(balance).toBeLessThanOrEqual(LAMPORTS_PER_SOL);
// accountFrom should have exactly 2, since it didn't pay for the transaction // accountFrom should have exactly 2, since it didn't pay for the transaction
mockRpc.push([ mockRpc.push([