fix: update ConfirmedBlock handling to match solana upstream
This commit is contained in:
committed by
Michael Vines
parent
77745a278d
commit
a461d5f25f
@ -426,12 +426,26 @@ test('get confirmed block', async () => {
|
||||
}
|
||||
const connection = new Connection(url);
|
||||
|
||||
// These test cases need to be updated when upstream solana RPC api is fleshed out
|
||||
const zeroTransactions = await connection.getConfirmedBlock(0);
|
||||
expect(zeroTransactions.length).toBe(0);
|
||||
// Block 0 never has any transactions in automation localnet
|
||||
const block0 = await connection.getConfirmedBlock(0);
|
||||
const blockhash0 = block0.blockhash;
|
||||
expect(block0.transactions.length).toBe(0);
|
||||
expect(blockhash0).not.toBeNull();
|
||||
expect(block0.previousBlockhash).not.toBeNull();
|
||||
expect(block0.parentSlot).toBe(0);
|
||||
|
||||
const oneTransaction = await connection.getConfirmedBlock(1);
|
||||
expect(oneTransaction.length).toBe(1);
|
||||
// Find a block that has a transaction, usually Block 1
|
||||
let x = 1;
|
||||
while (x < 10) {
|
||||
const block1 = await connection.getConfirmedBlock(x);
|
||||
if (block1.transactions.length >= 1) {
|
||||
expect(block1.previousBlockhash).toBe(blockhash0);
|
||||
expect(block1.blockhash).not.toBeNull();
|
||||
expect(block1.parentSlot).toBe(0);
|
||||
break;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
});
|
||||
|
||||
test('get recent blockhash', async () => {
|
||||
|
@ -105,7 +105,7 @@ test('transaction from rpc result', () => {
|
||||
const rawBlockhash = new PublicKey(0).toBuffer();
|
||||
const rpcResult = {
|
||||
message: {
|
||||
account_keys: [
|
||||
accountKeys: [
|
||||
[5],
|
||||
new PublicKey(1).toBuffer(),
|
||||
new PublicKey(2).toBuffer(),
|
||||
@ -114,19 +114,19 @@ test('transaction from rpc result', () => {
|
||||
new PublicKey(5).toBuffer(),
|
||||
],
|
||||
header: {
|
||||
num_readonly_signed_accounts: 0,
|
||||
num_readonly_unsigned_accounts: 3,
|
||||
num_required_signatures: 2,
|
||||
num_ReadonlySignedAccounts: 0,
|
||||
numReadonlyUnsignedAccounts: 3,
|
||||
numRequiredSignatures: 2,
|
||||
},
|
||||
instructions: [
|
||||
[1],
|
||||
{
|
||||
accounts: [[3], 1, 2, 3],
|
||||
data: [[1], 0],
|
||||
program_id_index: 4,
|
||||
programIdIndex: 4,
|
||||
},
|
||||
],
|
||||
recent_blockhash: rawBlockhash,
|
||||
recentBlockhash: rawBlockhash,
|
||||
},
|
||||
signatures: [[2], Array(64).fill(1), Array(64).fill(2)],
|
||||
};
|
||||
|
Reference in New Issue
Block a user