chore: make Connection block tests less brittle (#23015)
This commit is contained in:
parent
541b5a4826
commit
c899685cb2
|
@ -1973,14 +1973,21 @@ describe('Connection', () => {
|
|||
},
|
||||
});
|
||||
|
||||
// Find a block that has a transaction, usually Block 1
|
||||
// Find a block that has a transaction
|
||||
// Compare data with parent
|
||||
let x = 1;
|
||||
while (x < 10) {
|
||||
const block1 = await connection.getBlock(x);
|
||||
if (block1 && block1.transactions.length >= 1) {
|
||||
expect(block1.previousBlockhash).to.eq(blockhash0);
|
||||
if (block1.parentSlot == 0) {
|
||||
expect(block1.previousBlockhash).to.eq(blockhash0);
|
||||
} else {
|
||||
const parentBlock = await connection.getBlock(block1.parentSlot);
|
||||
if (parentBlock) {
|
||||
expect(block1.previousBlockhash).to.eq(parentBlock.blockhash);
|
||||
}
|
||||
}
|
||||
expect(block1.blockhash).not.to.be.null;
|
||||
expect(block1.parentSlot).to.eq(0);
|
||||
expect(block1.transactions[0].transaction).not.to.be.null;
|
||||
break;
|
||||
}
|
||||
|
@ -2082,14 +2089,21 @@ describe('Connection', () => {
|
|||
},
|
||||
});
|
||||
|
||||
// Find a block that has a transaction, usually Block 1
|
||||
// Find a block that has a transaction
|
||||
// Compare data with parent
|
||||
let x = 1;
|
||||
while (x < 10) {
|
||||
const block1 = await connection.getConfirmedBlock(x);
|
||||
if (block1.transactions.length >= 1) {
|
||||
expect(block1.previousBlockhash).to.eq(blockhash0);
|
||||
if (block1.parentSlot == 0) {
|
||||
expect(block1.previousBlockhash).to.eq(blockhash0);
|
||||
} else {
|
||||
const parentBlock = await connection.getBlock(block1.parentSlot);
|
||||
if (parentBlock) {
|
||||
expect(block1.previousBlockhash).to.eq(parentBlock.blockhash);
|
||||
}
|
||||
}
|
||||
expect(block1.blockhash).not.to.be.null;
|
||||
expect(block1.parentSlot).to.eq(0);
|
||||
expect(block1.transactions[0].transaction).not.to.be.null;
|
||||
break;
|
||||
}
|
||||
|
@ -2219,14 +2233,21 @@ describe('Connection', () => {
|
|||
},
|
||||
});
|
||||
|
||||
// Find a block that has a transaction, usually Block 1
|
||||
// Find a block that has a transaction
|
||||
// Compare data with parent
|
||||
let x = 1;
|
||||
while (x < 10) {
|
||||
const block1 = await connection.getBlockSignatures(x);
|
||||
if (block1.signatures.length >= 1) {
|
||||
expect(block1.previousBlockhash).to.eq(blockhash0);
|
||||
if (block1.parentSlot == 0) {
|
||||
expect(block1.previousBlockhash).to.eq(blockhash0);
|
||||
} else {
|
||||
const parentBlock = await connection.getBlock(block1.parentSlot);
|
||||
if (parentBlock) {
|
||||
expect(block1.previousBlockhash).to.eq(parentBlock.blockhash);
|
||||
}
|
||||
}
|
||||
expect(block1.blockhash).not.to.be.null;
|
||||
expect(block1.parentSlot).to.eq(0);
|
||||
expect(block1.signatures[0]).not.to.be.null;
|
||||
expect(block1).to.not.have.property('rewards');
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue