Skip to content

Commit

Permalink
Merge pull request #50 from solana-developers/simplify-naming
Browse files Browse the repository at this point in the history
Simplify naming. This is just doing a before/after test.
  • Loading branch information
heyAyushh authored Sep 5, 2024
2 parents 0c0029e + 0a6145a commit a78c452
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,11 @@ describe("initializeKeypair", () => {
envVariableName: keypairVariableName,
};

const signerFirstLoad = await initializeKeypair(connection, options);
const userBefore = await initializeKeypair(connection, options);

// Check balance
const firstBalanceLoad = await connection.getBalance(
signerFirstLoad.publicKey,
);
assert.ok(firstBalanceLoad > 0);
const balanceBefore = await connection.getBalance(userBefore.publicKey);
assert.ok(balanceBefore > 0);

// Check that the environment variable was created
dotenv.config({ path: envFileName });
Expand All @@ -221,19 +219,17 @@ describe("initializeKeypair", () => {
}

// Now reload the environment and check it matches our test keypair
const signerSecondLoad = await initializeKeypair(connection, options);
const userAfter = await initializeKeypair(connection, options);

// Check the keypair is the same
assert.ok(signerFirstLoad.publicKey.equals(signerSecondLoad.publicKey));
assert.ok(userBefore.publicKey.equals(userAfter.publicKey));

// Check balance has not changed
const secondBalanceLoad = await connection.getBalance(
signerSecondLoad.publicKey,
);
assert.equal(firstBalanceLoad, secondBalanceLoad);
const balanceAfter = await connection.getBalance(userAfter.publicKey);
assert.equal(balanceBefore, balanceAfter);

// Check there is a secret key
assert.ok(signerSecondLoad.secretKey);
assert.ok(userAfter.secretKey);

await deleteFile(envFileName);
});
Expand Down
3 changes: 3 additions & 0 deletions src/lib/airdrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const DEFAULT_AIRDROP_AMOUNT = 1 * LAMPORTS_PER_SOL;
const DEFAULT_MINIMUM_BALANCE = 0.5 * LAMPORTS_PER_SOL;
const DEFAULT_ENV_KEYPAIR_VARIABLE_NAME = "PRIVATE_KEY";

// TODO: honestly initializeKeypair is a bit vague
// we can probably give this a better name,
// just not sure what yet
export const initializeKeypair = async (
connection: Connection,
options?: InitializeKeypairOptions,
Expand Down

0 comments on commit a78c452

Please sign in to comment.