validator-clone.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import * as anchor from "@project-serum/anchor";
  2. import { Program } from "@project-serum/anchor";
  3. import { assert } from "chai";
  4. import { ValidatorClone } from "../target/types/validator_clone";
  5. describe("validator-clone", () => {
  6. // Configure the client to use the local cluster.
  7. anchor.setProvider(anchor.Provider.env());
  8. const program = anchor.workspace.ValidatorClone as Program<ValidatorClone>;
  9. const connection = program.provider.connection;
  10. it("Cloned non-executable account", async () => {
  11. // Metadata program upgrade authority
  12. const account = "AqH29mZfQFgRpfwaPoTMWSKJ5kqauoc1FwVBRksZyQrt";
  13. const [accountInfo] = await anchor.utils.rpc.getMultipleAccounts(
  14. connection,
  15. [new anchor.web3.PublicKey(account)]
  16. );
  17. assert.isNotNull(accountInfo, "Account " + account + " not found");
  18. });
  19. it("Cloned bpf2-program account", async () => {
  20. // Memo program
  21. const account = "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr";
  22. const [accountInfo] = await anchor.utils.rpc.getMultipleAccounts(
  23. connection,
  24. [new anchor.web3.PublicKey(account)]
  25. );
  26. assert.isNotNull(accountInfo, "Account " + account + " not found");
  27. });
  28. it("Cloned bpf3-program accounts and their program data", async () => {
  29. const accounts = [
  30. // Metadata program
  31. "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s",
  32. // Metadata program executable data
  33. "PwDiXFxQsGra4sFFTT8r1QWRMd4vfumiWC1jfWNfdYT",
  34. // Solend program
  35. "So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo",
  36. // Solend program executable data
  37. "DMCvGv1fS5rMcAvEDPDDBawPqbDRSzJh2Bo6qXCmgJkR",
  38. ];
  39. const accountInfos = await anchor.utils.rpc.getMultipleAccounts(
  40. connection,
  41. accounts.map((acc) => new anchor.web3.PublicKey(acc))
  42. );
  43. accountInfos.forEach((acc, i) => {
  44. assert.isNotNull(acc, "Account " + accounts[i] + " not found");
  45. });
  46. });
  47. it("Cloned bpf3-program account and its program data (both explicitly declared)", async () => {
  48. const accounts = [
  49. // Mango v3 program
  50. "mv3ekLzLbnVPNxjSKvqBpU3ZeZXPQdEC3bp5MDEBG68",
  51. // Mango v3 program executable data
  52. "8DKwAVrCEVStDYNPCsmxHtUj8LH9oXNtkVRrBfpNKvhp",
  53. ];
  54. const accountInfos = await anchor.utils.rpc.getMultipleAccounts(
  55. connection,
  56. accounts.map((acc) => new anchor.web3.PublicKey(acc))
  57. );
  58. accountInfos.forEach((acc, i) => {
  59. assert.isNotNull(acc, "Account " + accounts[i] + " not found");
  60. });
  61. });
  62. });