@@ -2,11 +2,9 @@ import * as anchor from "@coral-xyz/anchor";
2
2
import { SolAnchorContract } from "../target/types/sol_anchor_contract" ;
3
3
4
4
describe ( "sol-anchor-contract" , ( ) => {
5
- const fs = require ( "fs" ) ;
6
- const assert = require ( "assert" ) ;
7
5
8
- let ethToUSD = "EdVCmQ9FSPcVe5YySXDPCRmc8aDQLKJ9xvYBMZPie1Vw" ;
9
- let usdtToUSD = "38xoQ4oeJCBrcVvca2cGk7iV1dAfrmTR1kmhSCJQ8Jto" ;
6
+ const ethToUSD = "EdVCmQ9FSPcVe5YySXDPCRmc8aDQLKJ9xvYBMZPie1Vw" ;
7
+ const usdtToUSD = "38xoQ4oeJCBrcVvca2cGk7iV1dAfrmTR1kmhSCJQ8Jto" ;
10
8
11
9
const provider = anchor . AnchorProvider . local ( ) ;
12
10
@@ -17,18 +15,14 @@ describe("sol-anchor-contract", () => {
17
15
const program = anchor . workspace
18
16
. SolAnchorContract as anchor . Program < SolAnchorContract > ;
19
17
const payer = provider . wallet . publicKey ;
20
- let programId = program . programId ;
21
- const programKey = program . programId ;
22
- console . log ( programKey )
23
-
18
+
24
19
it ( "Initialize the config." , async ( ) => {
25
20
const tx = await program . methods
26
21
. init ( {
27
22
loanPriceFeedId : new anchor . web3 . PublicKey ( ethToUSD ) ,
28
23
collateralPriceFeedId : new anchor . web3 . PublicKey ( usdtToUSD ) ,
29
24
} )
30
25
. accounts ( {
31
- program : programId ,
32
26
payer,
33
27
config : config . publicKey ,
34
28
systemProgram : anchor . web3 . SystemProgram . programId ,
@@ -54,30 +48,4 @@ describe("sol-anchor-contract", () => {
54
48
console . log ( "Loan2Value() is invoked: " + tx ) ;
55
49
} ) ;
56
50
57
- it ( "Prevent initialization of config without authority." , async ( ) => {
58
- const attacker = anchor . web3 . Keypair . generate ( ) ;
59
-
60
- var tx ,
61
- success = false ;
62
- try {
63
- tx = await program . methods
64
- . init ( {
65
- loanPriceFeedId : new anchor . web3 . PublicKey ( ethToUSD ) ,
66
- collateralPriceFeedId : new anchor . web3 . PublicKey ( usdtToUSD ) ,
67
- } )
68
- . accounts ( {
69
- program : programId ,
70
- payer,
71
- config : config . publicKey ,
72
- systemProgram : anchor . web3 . SystemProgram . programId ,
73
- } )
74
- . signers ( [ config , attacker ] )
75
- . rpc ( ) ;
76
-
77
- success = true ;
78
- } catch ( error ) {
79
- console . log ( "Attacker failed at unauthorized init" ) ;
80
- }
81
- if ( success ) throw new Error ( "Attacker succeeded! TxHash: " + tx ) ;
82
- } ) ;
83
51
} ) ;
0 commit comments