-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
430108a
commit a840831
Showing
3 changed files
with
162 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,41 @@ | ||
import { createDataItemSigner } from "@permaweb/aoconnect"; | ||
import { JWKInterface } from "arweave/node/lib/wallet"; | ||
import Token, { type TokenInstance } from "./Token"; | ||
import Quantity from "./Quantity"; | ||
import Arweave from "arweave"; | ||
|
||
describe("Token testing", () => { | ||
let token: TokenInstance; | ||
let wallet: JWKInterface; | ||
|
||
beforeAll(async () => { | ||
const arweave = new Arweave({ | ||
host: "arweave.net", | ||
port: 443, | ||
protocol: "https" | ||
}); | ||
wallet = await arweave.wallets.generate(); | ||
token = await Token( | ||
"Sa0iBLPNyJQrwpTTG-tWLQU-1QeUAJA73DdxGGiKoJc", | ||
createDataItemSigner(await arweave.wallets.generate()) | ||
createDataItemSigner(wallet) | ||
); | ||
}); | ||
}, 12000); | ||
|
||
test("Load token", () => { | ||
expect(token).not.toBeUndefined(); | ||
expect(token.info).not.toBeUndefined(); | ||
expect(typeof token.info?.Name).toBe("string"); | ||
}); | ||
|
||
test("Quantity is of token", async () => { | ||
const tkn = await Token( | ||
"Sa0iBLPNyJQrwpTTG-tWLQU-1QeUAJA73DdxGGiKoJc", | ||
createDataItemSigner(wallet) | ||
); | ||
const validQty = new Quantity(324n, 3n); | ||
const invalidQty = new Quantity(14529n, 5n); | ||
|
||
expect(Quantity.isQuantityOf(validQty, tkn)).toBeTruthy(); | ||
expect(Quantity.isQuantityOf(invalidQty, tkn)).toBeFalsy(); | ||
}); | ||
}); |