chore: cleanup flow and package.json
This commit is contained in:
committed by
Justin Starry
parent
c675c67c26
commit
f0a8aba2e2
@ -1,8 +1,9 @@
|
||||
// @flow
|
||||
import {Account} from '../src/account';
|
||||
import {expect} from 'chai';
|
||||
import {Buffer} from 'buffer';
|
||||
|
||||
import {Account} from '../src/account';
|
||||
|
||||
describe('Account', () => {
|
||||
it('generate new account', () => {
|
||||
const account = new Account();
|
||||
|
@ -1,7 +1,8 @@
|
||||
// @flow
|
||||
|
||||
import {AgentManager, DESTROY_TIMEOUT_MS} from '../src/agent-manager';
|
||||
import {expect} from 'chai';
|
||||
|
||||
import {AgentManager, DESTROY_TIMEOUT_MS} from '../src/agent-manager';
|
||||
import {sleep} from '../src/util/sleep';
|
||||
|
||||
describe('AgentManager', () => {
|
||||
|
@ -1,7 +1,9 @@
|
||||
// @flow
|
||||
import {clusterApiUrl} from '../src/util/cluster';
|
||||
|
||||
import {expect} from 'chai';
|
||||
|
||||
import {clusterApiUrl} from '../src/util/cluster';
|
||||
|
||||
describe('Cluster Util', () => {
|
||||
it('invalid', () => {
|
||||
expect(() => {
|
||||
|
@ -21,29 +21,20 @@ import {DEFAULT_TICKS_PER_SLOT, NUM_TICKS_PER_SECOND} from '../src/timing';
|
||||
import {MOCK_PORT, url} from './url';
|
||||
import {BLOCKHASH_CACHE_TIMEOUT_MS} from '../src/connection';
|
||||
import {sleep} from '../src/util/sleep';
|
||||
import type {TransactionSignature} from '../src/transaction';
|
||||
import type {
|
||||
Commitment,
|
||||
SignatureStatus,
|
||||
TransactionError,
|
||||
KeyedAccountInfo,
|
||||
SlotInfo,
|
||||
} from '../src/connection';
|
||||
|
||||
import {
|
||||
helpers,
|
||||
mockErrorMessage,
|
||||
mockErrorResponse,
|
||||
uniqueSignature,
|
||||
uniqueBlockhash,
|
||||
mockRpcResponse,
|
||||
mockServer,
|
||||
} from './mocks/rpc-http';
|
||||
import {
|
||||
stubRpcWebSocket,
|
||||
restoreRpcWebSocket,
|
||||
mockRpcMessage,
|
||||
} from './mocks/rpc-websockets';
|
||||
import {stubRpcWebSocket, restoreRpcWebSocket} from './mocks/rpc-websockets';
|
||||
import type {TransactionSignature} from '../src/transaction';
|
||||
import type {
|
||||
SignatureStatus,
|
||||
TransactionError,
|
||||
KeyedAccountInfo,
|
||||
} from '../src/connection';
|
||||
|
||||
use(chaiAsPromised);
|
||||
|
||||
@ -1712,12 +1703,9 @@ describe('Connection', () => {
|
||||
lamports: 9,
|
||||
}),
|
||||
);
|
||||
const signature3 = await sendAndConfirmTransaction(
|
||||
connection,
|
||||
transaction3,
|
||||
[accountFrom],
|
||||
{preflightCommitment: 'singleGossip'},
|
||||
);
|
||||
await sendAndConfirmTransaction(connection, transaction3, [accountFrom], {
|
||||
preflightCommitment: 'singleGossip',
|
||||
});
|
||||
expect(transaction2.recentBlockhash).to.eq(transaction3.recentBlockhash);
|
||||
|
||||
// Sleep until blockhash cache times out
|
||||
@ -1956,7 +1944,7 @@ describe('Connection', () => {
|
||||
});
|
||||
|
||||
it('slot notification', async () => {
|
||||
let notifiedSlotInfo: SlotInfo;
|
||||
let notifiedSlotInfo;
|
||||
const subscriptionId = connection.onSlotChange(slotInfo => {
|
||||
notifiedSlotInfo = slotInfo;
|
||||
});
|
||||
|
7
web3.js/test/fixtures/noop-c/build.sh
vendored
Executable file
7
web3.js/test/fixtures/noop-c/build.sh
vendored
Executable file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -ex
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
make -C ../../../examples/bpf-c-noop/
|
||||
cp ../../../examples/bpf-c-noop/out/noop.so .
|
7
web3.js/test/fixtures/noop-rust/build.sh
vendored
Executable file
7
web3.js/test/fixtures/noop-rust/build.sh
vendored
Executable file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -ex
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
cargo build-bpf --manifest-path=../../../examples/bpf-rust-noop/Cargo.toml
|
||||
cp ../../../examples/bpf-rust-noop/target/deploy/solana_bpf_rust_noop.so .
|
@ -3,12 +3,13 @@
|
||||
import bs58 from 'bs58';
|
||||
import BN from 'bn.js';
|
||||
import * as mockttp from 'mockttp';
|
||||
import {mockRpcMessage} from './rpc-websockets';
|
||||
|
||||
import {Connection} from '../../src';
|
||||
import {mockRpcMessage} from './rpc-websockets';
|
||||
import {Account, Connection, PublicKey, Transaction} from '../../src';
|
||||
import type {Commitment} from '../../src/connection';
|
||||
|
||||
export const mockServer = process.env.TEST_LIVE || mockttp.getLocal();
|
||||
export const mockServer: mockttp.Mockttp =
|
||||
process.env.TEST_LIVE || mockttp.getLocal();
|
||||
|
||||
let uniqueCounter = 0;
|
||||
export const uniqueSignature = () => {
|
||||
@ -33,19 +34,22 @@ export const mockRpcResponse = async ({
|
||||
}: {
|
||||
method: string,
|
||||
params: Array<any>,
|
||||
value: any,
|
||||
error: any,
|
||||
value?: any,
|
||||
error?: any,
|
||||
withContext?: boolean,
|
||||
}) => {
|
||||
if (process.env.TEST_LIVE) return;
|
||||
let result = withContext
|
||||
? {
|
||||
context: {
|
||||
slot: 11,
|
||||
},
|
||||
value,
|
||||
}
|
||||
: value;
|
||||
|
||||
let result = value;
|
||||
if (withContext) {
|
||||
result = {
|
||||
context: {
|
||||
slot: 11,
|
||||
},
|
||||
value,
|
||||
};
|
||||
}
|
||||
|
||||
await mockServer
|
||||
.post('/')
|
||||
.withJsonBodyIncluding({
|
||||
@ -69,7 +73,7 @@ const recentBlockhash = async ({
|
||||
commitment,
|
||||
}: {
|
||||
connection: Connection,
|
||||
commitment: ?Commitment,
|
||||
commitment?: Commitment,
|
||||
}) => {
|
||||
const blockhash = uniqueBlockhash();
|
||||
const params = [];
|
||||
@ -117,13 +121,16 @@ const processTransaction = async ({
|
||||
value: signature,
|
||||
});
|
||||
|
||||
const sendOptions = err
|
||||
? {
|
||||
skipPreflight: true,
|
||||
}
|
||||
: {
|
||||
preflightCommitment: commitment,
|
||||
};
|
||||
let sendOptions;
|
||||
if (err) {
|
||||
sendOptions = {
|
||||
skipPreflight: true,
|
||||
};
|
||||
} else {
|
||||
sendOptions = {
|
||||
preflightCommitment: commitment,
|
||||
};
|
||||
}
|
||||
|
||||
await connection.sendEncodedTransaction(encoded, sendOptions);
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
import {Client as LiveClient} from 'rpc-websockets';
|
||||
import {expect} from 'chai';
|
||||
import sinon from 'sinon';
|
||||
|
||||
import {Connection} from '../../src';
|
||||
|
||||
type RpcRequest = {
|
||||
@ -62,6 +63,7 @@ export const restoreRpcWebSocket = (connection: Connection) => {
|
||||
};
|
||||
|
||||
class MockClient {
|
||||
client: LiveClient;
|
||||
mockOpen = false;
|
||||
subscriptionCounter = 0;
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
// @flow
|
||||
import BN from 'bn.js';
|
||||
import {Buffer} from 'buffer';
|
||||
import {PublicKey, MAX_SEED_LENGTH} from '../src/publickey';
|
||||
import {expect, use} from 'chai';
|
||||
import chaiAsPromised from 'chai-as-promised';
|
||||
|
||||
import {PublicKey, MAX_SEED_LENGTH} from '../src/publickey';
|
||||
|
||||
use(chaiAsPromised);
|
||||
|
||||
describe('PublicKey', function () {
|
||||
|
@ -10,11 +10,6 @@ import replace from '@rollup/plugin-replace';
|
||||
|
||||
export default {
|
||||
input: {
|
||||
// include: [
|
||||
// 'test/account.test.js',
|
||||
// 'test/cluster.test.js',
|
||||
// 'test/stake-program.test.js',
|
||||
// ],
|
||||
include: ['test/**/*.test.js'],
|
||||
exclude: ['test/agent-manager.test.js', 'test/bpf-loader.test.js'],
|
||||
},
|
||||
|
@ -1,7 +1,7 @@
|
||||
// @flow
|
||||
|
||||
import {Buffer} from 'buffer';
|
||||
import createKeccakHash from 'keccak';
|
||||
import {keccak_256} from 'js-sha3';
|
||||
import {privateKeyVerify, ecdsaSign, publicKeyCreate} from 'secp256k1';
|
||||
|
||||
import {
|
||||
@ -13,7 +13,7 @@ import {
|
||||
Secp256k1Program,
|
||||
} from '../src';
|
||||
import {url} from './url';
|
||||
import {helpers} from './mocks/rpc-http';
|
||||
import {toBuffer} from '../src/util/to-buffer';
|
||||
|
||||
const randomPrivateKey = () => {
|
||||
let privateKey;
|
||||
@ -29,9 +29,9 @@ if (process.env.TEST_LIVE) {
|
||||
const privateKey = randomPrivateKey();
|
||||
const publicKey = publicKeyCreate(privateKey, false);
|
||||
const message = Buffer.from('This is a message');
|
||||
const messageHash = createKeccakHash('keccak256')
|
||||
.update(message)
|
||||
.digest();
|
||||
const messageHash = Buffer.from(
|
||||
keccak_256.update(toBuffer(message)).digest(),
|
||||
);
|
||||
const {signature, recid: recoveryId} = ecdsaSign(messageHash, privateKey);
|
||||
const connection = new Connection(url, 'singleGossip');
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
// @flow
|
||||
|
||||
import {expect} from 'chai';
|
||||
|
||||
import {decodeLength, encodeLength} from '../src/util/shortvec-encoding';
|
||||
|
||||
function checkDecodedArray(array: Array<number>, expectedValue: number) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
// @flow
|
||||
|
||||
import base58 from 'bs58';
|
||||
import {expect} from 'chai';
|
||||
|
||||
import {
|
||||
@ -10,22 +11,8 @@ import {
|
||||
LAMPORTS_PER_SOL,
|
||||
} from '../src';
|
||||
import {MOCK_PORT, url} from './url';
|
||||
|
||||
import {
|
||||
helpers,
|
||||
mockErrorMessage,
|
||||
mockErrorResponse,
|
||||
uniqueSignature,
|
||||
uniqueBlockhash,
|
||||
mockRpcResponse,
|
||||
mockServer,
|
||||
} from './mocks/rpc-http';
|
||||
import {
|
||||
stubRpcWebSocket,
|
||||
restoreRpcWebSocket,
|
||||
mockRpcMessage,
|
||||
} from './mocks/rpc-websockets';
|
||||
import base58 from 'bs58';
|
||||
import {helpers, mockRpcResponse, mockServer} from './mocks/rpc-http';
|
||||
import {stubRpcWebSocket, restoreRpcWebSocket} from './mocks/rpc-websockets';
|
||||
|
||||
describe('Transaction Payer', () => {
|
||||
let connection: Connection;
|
||||
|
@ -2,7 +2,7 @@
|
||||
import bs58 from 'bs58';
|
||||
import {Buffer} from 'buffer';
|
||||
import nacl from 'tweetnacl';
|
||||
import {expect, use} from 'chai';
|
||||
import {expect} from 'chai';
|
||||
|
||||
import {Account} from '../src/account';
|
||||
import {PublicKey} from '../src/publickey';
|
||||
|
Reference in New Issue
Block a user