fix: rename tokens to lamports

This commit is contained in:
Michael Vines
2019-03-05 17:52:13 -08:00
parent 09b6d2b764
commit be8821e0d0
12 changed files with 68 additions and 68 deletions

View File

@ -10,7 +10,7 @@ import {
} from '../src';
import {mockRpcEnabled} from './__mocks__/node-fetch';
import {url} from './url';
import {newAccountWithTokens} from './new-account-with-tokens';
import {newAccountWithLamports} from './new-account-with-lamports';
if (!mockRpcEnabled) {
// The default of 5 seconds is too slow for live testing sometimes
@ -24,7 +24,7 @@ test('load BPF program', async () => {
}
const connection = new Connection(url);
const from = await newAccountWithTokens(connection, 1024);
const from = await newAccountWithLamports(connection, 1024);
const data = await fs.readFile('test/fixtures/noop/noop.so');
const programId = await BpfLoader.load(connection, from, data);
const transaction = new Transaction().add({

View File

@ -213,7 +213,7 @@ test('request airdrop', async () => {
0,
0,
],
tokens: 42,
lamports: 42,
userdata: [],
executable: false,
},
@ -221,7 +221,7 @@ test('request airdrop', async () => {
]);
const accountInfo = await connection.getAccountInfo(account.publicKey);
expect(accountInfo.tokens).toBe(42);
expect(accountInfo.lamports).toBe(42);
expect(accountInfo.userdata).toHaveLength(0);
expect(accountInfo.owner).toEqual(SystemProgram.programId);
});
@ -469,7 +469,7 @@ test('account change notification', async () => {
await connection.removeAccountChangeListener(subscriptionId);
expect(mockCallback.mock.calls[0][0].tokens).toBe(41);
expect(mockCallback.mock.calls[0][0].lamports).toBe(41);
expect(mockCallback.mock.calls[0][0].owner).toEqual(BpfLoader.programId);
expect(mockCallback.mock.calls[0][0].executable).toBe(false);
expect(mockCallback.mock.calls[0][0].userdata).toEqual(

View File

@ -8,7 +8,7 @@ import {
} from '../src';
import {mockRpcEnabled} from './__mocks__/node-fetch';
import {url} from './url';
import {newAccountWithTokens} from './new-account-with-tokens';
import {newAccountWithLamports} from './new-account-with-lamports';
if (!mockRpcEnabled) {
// The default of 5 seconds is too slow for live testing sometimes
@ -22,7 +22,7 @@ test('load native program', async () => {
}
const connection = new Connection(url);
const from = await newAccountWithTokens(connection, 1024);
const from = await newAccountWithLamports(connection, 1024);
const programId = await NativeLoader.load(connection, from, 'noop');
const transaction = new Transaction().add({
keys: [from.publicKey],

View File

@ -4,9 +4,9 @@ import {Account, Connection} from '../src';
import {mockRpc} from './__mocks__/node-fetch';
import {url} from './url';
export async function newAccountWithTokens(
export async function newAccountWithLamports(
connection: Connection,
amount: number = 10,
lamports: number = 10,
): Promise<Account> {
const account = new Account();
@ -15,7 +15,7 @@ export async function newAccountWithTokens(
url,
{
method: 'requestAirdrop',
params: [account.publicKey.toBase58(), amount],
params: [account.publicKey.toBase58(), lamports],
},
{
error: null,
@ -26,6 +26,6 @@ export async function newAccountWithTokens(
]);
}
await connection.requestAirdrop(account.publicKey, amount);
await connection.requestAirdrop(account.publicKey, lamports);
return account;
}

View File

@ -4,7 +4,7 @@ import {Connection, PublicKey, Token, TokenAmount} from '../src';
import {SYSTEM_TOKEN_PROGRAM_ID} from '../src/token-program';
import {mockRpc, mockRpcEnabled} from './__mocks__/node-fetch';
import {url} from './url';
import {newAccountWithTokens} from './new-account-with-tokens';
import {newAccountWithLamports} from './new-account-with-lamports';
import {mockGetRecentBlockhash} from './mockrpc/get-recent-blockhash';
import {sleep} from '../src/util/sleep';
@ -50,7 +50,7 @@ test('create new token', async () => {
const connection = new Connection(url);
connection._disableBlockhashCaching = mockRpcEnabled;
initialOwner = await newAccountWithTokens(connection, 1024);
initialOwner = await newAccountWithLamports(connection, 1024);
{
// mock SystemProgram.createAccount transaction for Token.createNewToken()
@ -94,7 +94,7 @@ test('create new token', async () => {
error: null,
result: {
owner: [...SYSTEM_TOKEN_PROGRAM_ID.toBuffer()],
tokens: 1,
lamports: 1,
userdata: [
1,
16,
@ -162,7 +162,7 @@ test('create new token', async () => {
error: null,
result: {
owner: [...SYSTEM_TOKEN_PROGRAM_ID.toBuffer()],
tokens: 1,
lamports: 1,
userdata: [
2,
...testToken.token.toBuffer(),
@ -226,7 +226,7 @@ test('create new token', async () => {
test('create new token account', async () => {
const connection = new Connection(url);
connection._disableBlockhashCaching = mockRpcEnabled;
const destOwner = await newAccountWithTokens(connection);
const destOwner = await newAccountWithLamports(connection);
{
// mock SystemProgram.createAccount transaction for Token.newAccount()
@ -251,7 +251,7 @@ test('create new token account', async () => {
error: null,
result: {
owner: [...SYSTEM_TOKEN_PROGRAM_ID.toBuffer()],
tokens: 1,
lamports: 1,
userdata: [
2,
...testToken.token.toBuffer(),
@ -283,7 +283,7 @@ test('create new token account', async () => {
test('transfer', async () => {
const connection = new Connection(url);
connection._disableBlockhashCaching = mockRpcEnabled;
const destOwner = await newAccountWithTokens(connection);
const destOwner = await newAccountWithLamports(connection);
{
// mock SystemProgram.createAccount transaction for Token.newAccount()
@ -309,7 +309,7 @@ test('transfer', async () => {
error: null,
result: {
owner: [...SYSTEM_TOKEN_PROGRAM_ID.toBuffer()],
tokens: 1,
lamports: 1,
userdata: [
2,
...testToken.token.toBuffer(),
@ -348,7 +348,7 @@ test('transfer', async () => {
error: null,
result: {
owner: [...SYSTEM_TOKEN_PROGRAM_ID.toBuffer()],
tokens: 1,
lamports: 1,
userdata: [
2,
...testToken.token.toBuffer(),
@ -378,7 +378,7 @@ test('transfer', async () => {
test('approve/revoke', async () => {
const connection = new Connection(url);
connection._disableBlockhashCaching = mockRpcEnabled;
const delegateOwner = await newAccountWithTokens(connection);
const delegateOwner = await newAccountWithLamports(connection);
{
// mock SystemProgram.createAccount transaction for Token.newAccount()
@ -419,7 +419,7 @@ test('approve/revoke', async () => {
error: null,
result: {
owner: [...SYSTEM_TOKEN_PROGRAM_ID.toBuffer()],
tokens: 1,
lamports: 1,
userdata: [
2,
...testToken.token.toBuffer(),
@ -481,7 +481,7 @@ test('approve/revoke', async () => {
error: null,
result: {
owner: [...SYSTEM_TOKEN_PROGRAM_ID.toBuffer()],
tokens: 1,
lamports: 1,
userdata: [
2,
...testToken.token.toBuffer(),
@ -530,7 +530,7 @@ test('invalid approve', async () => {
}
const connection = new Connection(url);
const owner = await newAccountWithTokens(connection);
const owner = await newAccountWithLamports(connection);
const account1 = await testToken.newAccount(owner);
const account1Delegate = await testToken.newAccount(owner, account1);
@ -554,7 +554,7 @@ test('fail on approve overspend', async () => {
}
const connection = new Connection(url);
const owner = await newAccountWithTokens(connection);
const owner = await newAccountWithLamports(connection);
const account1 = await testToken.newAccount(owner);
const account1Delegate = await testToken.newAccount(owner, account1);
@ -597,8 +597,8 @@ test('set owner', async () => {
}
const connection = new Connection(url);
const owner = await newAccountWithTokens(connection);
const newOwner = await newAccountWithTokens(connection);
const owner = await newAccountWithLamports(connection);
const newOwner = await newAccountWithLamports(connection);
const account = await testToken.newAccount(owner);