Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 05bdcb2

Browse files
committed
add name service program upload workflow and js-test changes
1 parent a6704a9 commit 05bdcb2

File tree

2 files changed

+34
-19
lines changed

2 files changed

+34
-19
lines changed

.github/workflows/pull-request-name-service.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ jobs:
5757
- name: Build and test
5858
run: ./ci/cargo-test-sbf.sh name-service
5959

60+
- name: Upload programs
61+
uses: actions/upload-artifact@v2
62+
with:
63+
name: name-service-programs
64+
path: "target/deploy/*.so"
65+
if-no-files-found: error
66+
6067
js-test:
6168
runs-on: ubuntu-latest
6269
env:
@@ -73,4 +80,9 @@ jobs:
7380
key: node-${{ hashFiles('name-service/js/yarn.lock') }}
7481
restore-keys: |
7582
node-
83+
- name: Download programs
84+
uses: actions/download-artifact@v2
85+
with:
86+
name: name-service-programs
87+
path: target/deploy
7688
- run: ./ci/js-test-name-service.sh

name-service/js/test/e2e/index.test.ts

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,27 @@ import {
2323
chai.use(chaiAsPromised);
2424
const url = 'http://localhost:8899';
2525

26-
describe('Name Service Program', () => {
27-
let connection: Connection;
28-
let payer: Keypair;
29-
let owner: Keypair;
26+
describe('Name Service Program', async () => {
27+
const connection = new Connection(url, 'confirmed');
28+
const payer = Keypair.generate();
29+
const owner = Keypair.generate();
30+
const space = 20;
3031
let nameKey: PublicKey;
31-
const name = '.sol';
32+
let name: string;
3233
before(async () => {
33-
connection = new Connection(url, 'confirmed');
34-
payer = Keypair.generate();
3534
const airdropSignature = await connection.requestAirdrop(
3635
payer.publicKey,
37-
4 * LAMPORTS_PER_SOL
36+
LAMPORTS_PER_SOL
3837
);
39-
await connection.confirmTransaction(airdropSignature, 'confirmed');
38+
await connection.confirmTransaction({
39+
signature: airdropSignature,
40+
...(await connection.getLatestBlockhash()),
41+
});
42+
});
43+
44+
beforeEach(async () => {
45+
name = Math.random().toString() + '.sol';
4046
nameKey = await getNameKey(name);
41-
owner = Keypair.generate();
42-
const space = 20;
4347
const lamports = await connection.getMinimumBalanceForRentExemption(
4448
space + NameRegistryState.HEADER_LEN
4549
);
@@ -58,7 +62,7 @@ describe('Name Service Program', () => {
5862
it('Create Name Registery', async () => {
5963
const nameAccount = await NameRegistryState.retrieve(connection, nameKey);
6064
nameAccount.owner.equals(owner.publicKey);
61-
expect(nameAccount.data?.length).to.eql(20);
65+
expect(nameAccount.data?.length).to.eql(space);
6266
});
6367
it('Update Name Registery', async () => {
6468
const data = Buffer.from('@Dudl');
@@ -79,31 +83,30 @@ describe('Name Service Program', () => {
7983
await sendAndConfirmTransaction(connection, tx, [payer, owner]);
8084
const nameAccount = await NameRegistryState.retrieve(connection, nameKey);
8185
nameAccount.owner.equals(newOwner.publicKey);
82-
owner = newOwner;
8386
});
8487
it('Realloc Name Account to bigger space', async () => {
8588
const inst = await reallocNameAccount(
8689
connection,
8790
name,
88-
30,
91+
space + 10,
8992
payer.publicKey
9093
);
9194
const tx = new Transaction().add(inst);
9295
await sendAndConfirmTransaction(connection, tx, [payer, owner]);
9396
const nameAccount = await NameRegistryState.retrieve(connection, nameKey);
94-
expect(nameAccount.data?.length).to.eql(30);
97+
expect(nameAccount.data?.length).to.eql(space + 10);
9598
});
9699
it('Realloc Name Account to smaller space', async () => {
97100
const inst = await reallocNameAccount(
98101
connection,
99102
name,
100-
10,
103+
space - 10,
101104
payer.publicKey
102105
);
103106
const tx = new Transaction().add(inst);
104107
await sendAndConfirmTransaction(connection, tx, [payer, owner]);
105108
const nameAccount = await NameRegistryState.retrieve(connection, nameKey);
106-
expect(nameAccount.data?.length).to.eql(10);
109+
expect(nameAccount.data?.length).to.eql(space - 10);
107110
});
108111
it('Delete Name Registry', async () => {
109112
const inst = await deleteNameRegistry(connection, name, payer.publicKey);
@@ -119,9 +122,9 @@ const getNameKey = async (
119122
nameClass?: PublicKey,
120123
parentName?: PublicKey
121124
) => {
122-
const hashed_name = await getHashedName(name);
125+
const hashedName = await getHashedName(name);
123126
const nameAccountKey = await getNameAccountKey(
124-
hashed_name,
127+
hashedName,
125128
nameClass,
126129
parentName
127130
);

0 commit comments

Comments
 (0)