Skip to content

Commit

Permalink
feat: Agave v2 RPC: replace getConfirmedBlock with getBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Oct 23, 2024
1 parent 60a94b1 commit 2fe2282
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
3 changes: 2 additions & 1 deletion scripts/get-latest-validator-release-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
if [ -z $version ]; then
exit 3
fi
echo $version
# echo $version
echo "v2.0.0"
)
errorCode=$?
if [ $errorCode -ne 0 ]; then
Expand Down
4 changes: 2 additions & 2 deletions src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5223,7 +5223,7 @@ export class Connection {
commitment?: Finality,
): Promise<ConfirmedBlock> {
const args = this._buildArgsAtLeastConfirmed([slot], commitment);
const unsafeRes = await this._rpcRequest('getConfirmedBlock', args);
const unsafeRes = await this._rpcRequest('getBlock', args);
const res = create(unsafeRes, GetConfirmedBlockRpcResult);

if ('error' in res) {
Expand Down Expand Up @@ -5329,7 +5329,7 @@ export class Connection {
rewards: false,
},
);
const unsafeRes = await this._rpcRequest('getConfirmedBlock', args);
const unsafeRes = await this._rpcRequest('getBlock', args);
const res = create(unsafeRes, GetBlockSignaturesRpcResult);
if ('error' in res) {
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
Expand Down
22 changes: 11 additions & 11 deletions test/connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2351,7 +2351,7 @@ describe('Connection', function () {
await waitForSlot.call(this, connection, 1);

await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [1],
value: {
blockTime: 1614281964,
Expand Down Expand Up @@ -2433,7 +2433,7 @@ describe('Connection', function () {
const mockSignature =
'5SHZ9NwpnS9zYnauN7pnuborKf39zGMr11XpMC59VvRSeDJNcnYLecmdxXCVuBFPNQLdCBBjyZiNCL4KoHKr3tvz';
await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [slot, {transactionDetails: 'signatures', rewards: false}],
value: {
blockTime: 1614281964,
Expand All @@ -2449,7 +2449,7 @@ describe('Connection', function () {
value: 123,
});
await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [slot + 2, {transactionDetails: 'signatures', rewards: false}],
value: {
blockTime: 1614281964,
Expand Down Expand Up @@ -2482,7 +2482,7 @@ describe('Connection', function () {

const badSlot = Number.MAX_SAFE_INTEGER - 1;
await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [badSlot - 1, {transactionDetails: 'signatures', rewards: false}],
error: {message: 'Block not available for slot ' + badSlot},
});
Expand Down Expand Up @@ -2531,7 +2531,7 @@ describe('Connection', function () {
await waitForSlot.call(this, connection, 1);

await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [1],
value: {
blockTime: 1614281964,
Expand Down Expand Up @@ -2640,7 +2640,7 @@ describe('Connection', function () {
await waitForSlot.call(this, connection, 1);

await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [1],
value: {
blockTime: 1614281964,
Expand Down Expand Up @@ -3294,7 +3294,7 @@ describe('Connection', function () {
await waitForSlot.call(this, connection, 1);

await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [1],
value: {
blockTime: 1614281964,
Expand Down Expand Up @@ -4252,7 +4252,7 @@ describe('Connection', function () {

it('gets the genesis block', async function () {
await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [0],
value: {
blockHeight: 0,
Expand Down Expand Up @@ -4290,7 +4290,7 @@ describe('Connection', function () {
it('gets a block having a parent', async function () {
// Mock parent of block with transaction.
await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [0],
value: {
blockHeight: 0,
Expand All @@ -4303,7 +4303,7 @@ describe('Connection', function () {
});
// Mock block with transaction.
await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [1],
value: {
blockTime: 1614281964,
Expand Down Expand Up @@ -4390,7 +4390,7 @@ describe('Connection', function () {
.null;

await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [Number.MAX_SAFE_INTEGER],
error: {
message: `Block not available for slot ${Number.MAX_SAFE_INTEGER}`,
Expand Down

0 comments on commit 2fe2282

Please sign in to comment.