@@ -463,6 +463,9 @@ class EarnTest<V extends Variant = Variant.New> {
463463 this . getEarnGlobalAccount ( ) ,
464464 mint . publicKey ,
465465 AccountState . Frozen ,
466+ undefined ,
467+ false ,
468+ decimals ,
466469 ) ;
467470
468471 let tx = new Transaction ( ) ;
@@ -849,7 +852,7 @@ class EarnTest<V extends Variant = Variant.New> {
849852 case Variant . New :
850853 await this . earn . methods
851854 . initialize ( initialIndex ! )
852- . accounts ( {
855+ . accountsPartial ( {
853856 admin : this . admin . publicKey ,
854857 mMint : this . mMint . publicKey ,
855858 } )
@@ -862,6 +865,7 @@ class EarnTest<V extends Variant = Variant.New> {
862865 . accounts ( {
863866 admin : this . admin . publicKey ,
864867 mMint : this . mMint . publicKey ,
868+ oldMMint : this . oldMMint ! . publicKey ,
865869 } )
866870 . signers ( [ this . admin ] )
867871 . rpc ( ) ;
@@ -979,6 +983,7 @@ for (const variant of VARIANTS) {
979983 . accounts ( {
980984 admin : $ . admin . publicKey ,
981985 mMint : $ . mMint . publicKey ,
986+ oldMMint : $ . oldMMint ! . publicKey ,
982987 } )
983988 . signers ( [ $ . admin ] )
984989 . rpc ( ) ,
@@ -987,7 +992,7 @@ for (const variant of VARIANTS) {
987992 await $ . expectSystemError (
988993 $ . earn . methods
989994 . initialize ( initialIndex )
990- . accounts ( {
995+ . accountsPartial ( {
991996 admin : $ . admin . publicKey ,
992997 mMint : $ . mMint . publicKey ,
993998 } )
@@ -1013,6 +1018,7 @@ for (const variant of VARIANTS) {
10131018 admin : $ . admin . publicKey ,
10141019 mMint : $ . mMint . publicKey ,
10151020 globalAccount : wrongGlobalAccount ,
1021+ oldMMint : $ . oldMMint ! . publicKey ,
10161022 } )
10171023 . signers ( [ $ . admin ] )
10181024 . rpc ( ) ,
@@ -1046,6 +1052,7 @@ for (const variant of VARIANTS) {
10461052 . accountsPartial ( {
10471053 admin : $ . admin . publicKey ,
10481054 mMint : wrongMint . publicKey ,
1055+ oldMMint : $ . oldMMint ! . publicKey ,
10491056 tokenProgram : TOKEN_PROGRAM_ID ,
10501057 } )
10511058 . signers ( [ $ . admin ] )
@@ -1083,6 +1090,7 @@ for (const variant of VARIANTS) {
10831090 . accountsPartial ( {
10841091 admin : $ . admin . publicKey ,
10851092 mMint : $ . mMint . publicKey ,
1093+ oldMMint : $ . oldMMint ! . publicKey ,
10861094 portalTokenAuthority : wrongPortalAuthority ,
10871095 } )
10881096 . signers ( [ $ . admin ] )
@@ -1119,6 +1127,7 @@ for (const variant of VARIANTS) {
11191127 . accountsPartial ( {
11201128 admin : $ . admin . publicKey ,
11211129 mMint : $ . mMint . publicKey ,
1130+ oldMMint : $ . oldMMint ! . publicKey ,
11221131 extSwapGlobal : wrongExtSwapGlobal ,
11231132 } )
11241133 . signers ( [ $ . admin ] )
@@ -1153,6 +1162,7 @@ for (const variant of VARIANTS) {
11531162 . accountsPartial ( {
11541163 admin : $ . admin . publicKey ,
11551164 mMint : wrongMint . publicKey ,
1165+ oldMMint : $ . oldMMint ! . publicKey ,
11561166 } )
11571167 . signers ( [ $ . admin ] )
11581168 . rpc ( ) ,
@@ -1187,6 +1197,7 @@ for (const variant of VARIANTS) {
11871197 . accountsPartial ( {
11881198 admin : $ . admin . publicKey ,
11891199 mMint : wrongMint . publicKey ,
1200+ oldMMint : $ . oldMMint ! . publicKey ,
11901201 } )
11911202 . signers ( [ $ . admin ] )
11921203 . rpc ( ) ,
@@ -1220,6 +1231,7 @@ for (const variant of VARIANTS) {
12201231 . accountsPartial ( {
12211232 admin : $ . admin . publicKey ,
12221233 mMint : mint . publicKey ,
1234+ oldMMint : $ . oldMMint ! . publicKey ,
12231235 } )
12241236 . signers ( [ $ . admin ] )
12251237 . rpc ( ) ,
@@ -1258,6 +1270,10 @@ for (const variant of VARIANTS) {
12581270 // migrate test cases
12591271 // [X] given the old global account does not match the seed + program ID
12601272 // [X] it reverts with a constraint seed error
1273+ // [ ] given the new m mint doesn't have the same decimals as the old one
1274+ // [ ] it reverts with a mint decimals error
1275+ // [ ] given the effective supply of the new mint is greater than than the supply of the old mint
1276+ // [ ] it reverts with an invalid mint error
12611277 // [X] given all the accounts are correct
12621278 // [X] the global account is created
12631279 // [X] the admin is set to the signer
@@ -1289,12 +1305,47 @@ for (const variant of VARIANTS) {
12891305 . accountsPartial ( {
12901306 admin : $ . admin . publicKey ,
12911307 mMint : $ . mMint . publicKey ,
1308+ oldMMint : $ . oldMMint ! . publicKey ,
12921309 oldGlobalAccount : wrongGlobalAccount ,
12931310 } )
12941311 . signers ( [ $ . admin ] )
12951312 . rpc ( ) ,
12961313 ) ;
12971314 } ) ;
1315+
1316+ test ( 'New m mint has different decimals - reverts' , async ( ) => {
1317+ const wrongMint = new Keypair ( ) ;
1318+ await $ . createMMint ( wrongMint , $ . nonAdmin , 9 ) ;
1319+
1320+ await $ . expectAnchorError (
1321+ $ . earn . methods
1322+ . initialize ( )
1323+ . accountsPartial ( {
1324+ admin : $ . admin . publicKey ,
1325+ mMint : wrongMint . publicKey ,
1326+ oldMMint : $ . oldMMint ! . publicKey ,
1327+ } )
1328+ . signers ( [ $ . admin ] )
1329+ . rpc ( ) ,
1330+ 'ConstraintMintDecimals' ,
1331+ ) ;
1332+ } ) ;
1333+
1334+ test ( 'New m mint supply is too large - reverts' , async ( ) => {
1335+ await $ . mintM ( $ . admin . publicKey , new BN ( 100_000_000 ) ) ; // mint 100 m tokens to admin
1336+
1337+ await $ . expectSystemError (
1338+ $ . earn . methods
1339+ . initialize ( )
1340+ . accountsPartial ( {
1341+ admin : $ . admin . publicKey ,
1342+ mMint : $ . mMint . publicKey ,
1343+ oldMMint : $ . oldMMint ! . publicKey ,
1344+ } )
1345+ . signers ( [ $ . admin ] )
1346+ . rpc ( ) ,
1347+ ) ;
1348+ } ) ;
12981349 }
12991350
13001351 // given the admin signs the transaction
@@ -1310,14 +1361,15 @@ for (const variant of VARIANTS) {
13101361 . accounts ( {
13111362 admin : $ . admin . publicKey ,
13121363 mMint : $ . mMint . publicKey ,
1364+ oldMMint : $ . oldMMint ! . publicKey ,
13131365 } )
13141366 . signers ( [ $ . admin ] )
13151367 . rpc ( ) ;
13161368 } else {
13171369 // Create and send the transaction
13181370 await $ . earn . methods
13191371 . initialize ( initialIndex )
1320- . accounts ( {
1372+ . accountsPartial ( {
13211373 admin : $ . admin . publicKey ,
13221374 mMint : $ . mMint . publicKey ,
13231375 } )
0 commit comments