From 8b32e7c2e733a3d0669221d3d3688818fed2a22b Mon Sep 17 00:00:00 2001 From: Alexander Chuprov Date: Thu, 5 Dec 2024 17:14:56 +0300 Subject: [PATCH] [#135] frostfsid: Add migration tests Signed-off-by: Alexander Chuprov --- .gitignore | 2 + tests/frostfsid_test.go | 47 +++++++++++++++ .../migration/0.19.2/frostfsid/config.json | 1 + .../0.19.2/frostfsid/frostfsid_contract.nef | Bin 0 -> 6214 bytes .../migration/0.21.1/frostfsid/config.json | 1 + .../0.21.1/frostfsid/frostfsid_contract.nef | Bin 0 -> 6918 bytes tests/util.go | 56 ++++++++++++++++++ 7 files changed, 107 insertions(+) create mode 100755 tests/testdata/migration/0.19.2/frostfsid/config.json create mode 100755 tests/testdata/migration/0.19.2/frostfsid/frostfsid_contract.nef create mode 100755 tests/testdata/migration/0.21.1/frostfsid/config.json create mode 100755 tests/testdata/migration/0.21.1/frostfsid/frostfsid_contract.nef diff --git a/.gitignore b/.gitignore index b5ef81d..f974cc1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ *.nef *.manifest.json config.json +!tests/testdata/**/*.nef +!tests/testdata/**/config.json /vendor/ .idea /bin/ diff --git a/tests/frostfsid_test.go b/tests/frostfsid_test.go index 2f0865a..67a5e10 100644 --- a/tests/frostfsid_test.go +++ b/tests/frostfsid_test.go @@ -2,6 +2,7 @@ package tests import ( "errors" + "fmt" "path" "testing" @@ -649,6 +650,52 @@ func TestAdditionalKeyFromPrimarySubject(t *testing.T) { invoker.Invoke(t, stackitem.Null{}, addSubjectKeyMethod, subjAKeyAddr, subjDPrimaryKey.PublicKey().Bytes()) } +const frostfsidContractName = "frostfsid" + +func TestFrostfsid_Migration(t *testing.T) { + e := newExecutor(t) + + acc, err := wallet.NewAccount() + require.NoError(t, err) + + args := make([]any, 5) + args[0] = acc.ScriptHash() + + c := loadCompiledContract(t, e.CommitteeHash, fmt.Sprintf(contractPathFormat, v0_19_2, frostfsidContractName, frostfsidContractName), + fmt.Sprintf(manifestPathFormat, v0_19_2, frostfsidContractName)) + e.DeployContract(t, c, args) + updateContract(t, c, e, c.Hash, args) + + inv := testFrostFSIDInvoker{ + e: e, + contractHash: c.Hash, + owner: acc, + } + newSigner(t, e.CommitteeInvoker(c.Hash), acc) + require.NoError(t, err) + invoker := inv.OwnerInvoker() + + subjAPrimaryKey, err := keys.NewPrivateKey() + require.NoError(t, err) + + subjBPrimaryKey, err := keys.NewPrivateKey() + require.NoError(t, err) + subjBKeyAddr := subjBPrimaryKey.PublicKey().GetScriptHash() + + invoker.Invoke(t, stackitem.Null{}, createSubjectMethod, defaultNamespace, subjAPrimaryKey.PublicKey().Bytes()) + + invoker.Invoke(t, stackitem.Null{}, createSubjectMethod, defaultNamespace, subjBPrimaryKey.PublicKey().Bytes()) + + invoker.Invoke(t, stackitem.Null{}, addSubjectKeyMethod, subjBKeyAddr, subjAPrimaryKey.PublicKey().Bytes()) + + c1 := loadCompiledContract(t, e.CommitteeHash, fmt.Sprintf(contractPathFormat, v0_21_1, frostfsidContractName, frostfsidContractName), + fmt.Sprintf(manifestPathFormat, v0_21_1, frostfsidContractName)) + updateContractFail(t, c1, e, c.Hash, args, "frostfsid contract contains duplicate keys") + invoker.Invoke(t, stackitem.Null{}, deleteSubjectMethod, subjBKeyAddr) + updateContract(t, c1, e, c.Hash, args) + updateContract(t, c1, e, c.Hash, args) +} + func checkPublicKeyResult(t *testing.T, s *vm.Stack, err error, key *keys.PrivateKey) { if key == nil { require.ErrorContains(t, err, "not found") diff --git a/tests/testdata/migration/0.19.2/frostfsid/config.json b/tests/testdata/migration/0.19.2/frostfsid/config.json new file mode 100755 index 0000000..7d5de27 --- /dev/null +++ b/tests/testdata/migration/0.19.2/frostfsid/config.json @@ -0,0 +1 @@ +{"name":"Identity","abi":{"methods":[{"name":"_deploy","offset":0,"parameters":[{"name":"data","type":"Any"},{"name":"isUpdate","type":"Boolean"}],"returntype":"Void","safe":false},{"name":"addSubjectKey","offset":799,"parameters":[{"name":"addr","type":"Hash160"},{"name":"key","type":"PublicKey"}],"returntype":"Void","safe":false},{"name":"addSubjectToGroup","offset":4138,"parameters":[{"name":"addr","type":"Hash160"},{"name":"groupID","type":"Integer"}],"returntype":"Void","safe":false},{"name":"clearAdmin","offset":329,"parameters":[],"returntype":"Void","safe":false},{"name":"createGroup","offset":3165,"parameters":[{"name":"ns","type":"String"},{"name":"group","type":"String"}],"returntype":"Integer","safe":false},{"name":"createNamespace","offset":2771,"parameters":[{"name":"ns","type":"String"}],"returntype":"Void","safe":false},{"name":"createSubject","offset":495,"parameters":[{"name":"ns","type":"String"},{"name":"key","type":"PublicKey"}],"returntype":"Void","safe":false},{"name":"deleteGroup","offset":4763,"parameters":[{"name":"ns","type":"String"},{"name":"groupID","type":"Integer"}],"returntype":"Void","safe":false},{"name":"deleteGroupKV","offset":3989,"parameters":[{"name":"ns","type":"String"},{"name":"groupID","type":"Integer"},{"name":"key","type":"String"}],"returntype":"Void","safe":false},{"name":"deleteSubject","offset":1936,"parameters":[{"name":"addr","type":"Hash160"}],"returntype":"Void","safe":false},{"name":"deleteSubjectKV","offset":1771,"parameters":[{"name":"addr","type":"Hash160"},{"name":"key","type":"String"}],"returntype":"Void","safe":false},{"name":"getAdmin","offset":369,"parameters":[],"returntype":"Hash160","safe":true},{"name":"getGroup","offset":3359,"parameters":[{"name":"ns","type":"String"},{"name":"groupID","type":"Integer"}],"returntype":"Array","safe":true},{"name":"getGroupByName","offset":3640,"parameters":[{"name":"ns","type":"String"},{"name":"name","type":"String"}],"returntype":"Array","safe":true},{"name":"getGroupExtended","offset":3427,"parameters":[{"name":"ns","type":"String"},{"name":"groupID","type":"Integer"}],"returntype":"Array","safe":true},{"name":"getGroupIDByName","offset":3551,"parameters":[{"name":"ns","type":"String"},{"name":"name","type":"String"}],"returntype":"Integer","safe":true},{"name":"getNamespace","offset":2887,"parameters":[{"name":"ns","type":"String"}],"returntype":"Array","safe":true},{"name":"getNamespaceExtended","offset":2957,"parameters":[{"name":"ns","type":"String"}],"returntype":"Array","safe":true},{"name":"getSubject","offset":2135,"parameters":[{"name":"addr","type":"Hash160"}],"returntype":"Array","safe":true},{"name":"getSubjectByKey","offset":2448,"parameters":[{"name":"key","type":"PublicKey"}],"returntype":"Array","safe":true},{"name":"getSubjectByName","offset":2636,"parameters":[{"name":"ns","type":"String"},{"name":"name","type":"String"}],"returntype":"Array","safe":true},{"name":"getSubjectExtended","offset":2244,"parameters":[{"name":"addr","type":"Hash160"}],"returntype":"Array","safe":true},{"name":"getSubjectKeyByName","offset":2659,"parameters":[{"name":"ns","type":"String"},{"name":"name","type":"String"}],"returntype":"PublicKey","safe":true},{"name":"listGroupSubjects","offset":4735,"parameters":[{"name":"ns","type":"String"},{"name":"groupID","type":"Integer"}],"returntype":"InteropInterface","safe":true},{"name":"listGroups","offset":4112,"parameters":[{"name":"ns","type":"String"}],"returntype":"InteropInterface","safe":true},{"name":"listNamespaceSubjects","offset":3139,"parameters":[{"name":"ns","type":"String"}],"returntype":"InteropInterface","safe":true},{"name":"listNamespaces","offset":3111,"parameters":[],"returntype":"InteropInterface","safe":true},{"name":"listSubjects","offset":2743,"parameters":[],"returntype":"InteropInterface","safe":true},{"name":"removeSubjectFromGroup","offset":4439,"parameters":[{"name":"addr","type":"Hash160"},{"name":"groupID","type":"Integer"}],"returntype":"Void","safe":false},{"name":"removeSubjectKey","offset":1084,"parameters":[{"name":"addr","type":"Hash160"},{"name":"key","type":"PublicKey"}],"returntype":"Void","safe":false},{"name":"setAdmin","offset":288,"parameters":[{"name":"addr","type":"Hash160"}],"returntype":"Void","safe":false},{"name":"setGroupKV","offset":3854,"parameters":[{"name":"ns","type":"String"},{"name":"groupID","type":"Integer"},{"name":"key","type":"String"},{"name":"val","type":"String"}],"returntype":"Void","safe":false},{"name":"setGroupName","offset":3714,"parameters":[{"name":"ns","type":"String"},{"name":"groupID","type":"Integer"},{"name":"name","type":"String"}],"returntype":"Void","safe":false},{"name":"setSubjectKV","offset":1594,"parameters":[{"name":"addr","type":"Hash160"},{"name":"key","type":"String"},{"name":"val","type":"String"}],"returntype":"Void","safe":false},{"name":"setSubjectName","offset":1412,"parameters":[{"name":"addr","type":"Hash160"},{"name":"name","type":"String"}],"returntype":"Void","safe":false},{"name":"update","offset":395,"parameters":[{"name":"script","type":"ByteArray"},{"name":"manifest","type":"ByteArray"},{"name":"data","type":"Any"}],"returntype":"Void","safe":false},{"name":"version","offset":491,"parameters":[],"returntype":"Integer","safe":true}],"events":[{"name":"CreateSubject","parameters":[{"name":"subjectAddress","type":"Hash160"}]},{"name":"AddSubjectKey","parameters":[{"name":"subjectAddress","type":"Hash160"},{"name":"subjectKey","type":"PublicKey"}]},{"name":"RemoveSubjectKey","parameters":[{"name":"subjectAddress","type":"Hash160"},{"name":"subjectKey","type":"PublicKey"}]},{"name":"SetSubjectName","parameters":[{"name":"subjectAddress","type":"Hash160"},{"name":"name","type":"String"}]},{"name":"SetSubjectKV","parameters":[{"name":"subjectAddress","type":"Hash160"},{"name":"key","type":"String"},{"name":"value","type":"String"}]},{"name":"DeleteSubjectKV","parameters":[{"name":"subjectAddress","type":"Hash160"},{"name":"key","type":"String"}]},{"name":"DeleteSubject","parameters":[{"name":"subjectAddress","type":"Hash160"}]},{"name":"CreateNamespace","parameters":[{"name":"namespace","type":"String"}]},{"name":"AddSubjectToNamespace","parameters":[{"name":"subjectAddress","type":"Hash160"},{"name":"namespace","type":"String"}]},{"name":"RemoveSubjectFromNamespace","parameters":[{"name":"subjectAddress","type":"Hash160"},{"name":"namespace","type":"String"}]},{"name":"CreateGroup","parameters":[{"name":"namespace","type":"String"},{"name":"group","type":"String"}]},{"name":"SetGroupName","parameters":[{"name":"namespace","type":"String"},{"name":"groupID","type":"Integer"},{"name":"name","type":"String"}]},{"name":"SetGroupKV","parameters":[{"name":"namespace","type":"String"},{"name":"groupID","type":"Integer"},{"name":"key","type":"String"},{"name":"value","type":"String"}]},{"name":"DeleteGroupKV","parameters":[{"name":"namespace","type":"String"},{"name":"groupID","type":"Integer"},{"name":"key","type":"String"}]},{"name":"AddSubjectToGroup","parameters":[{"name":"subjectAddress","type":"Hash160"},{"name":"namespace","type":"String"},{"name":"groupID","type":"Integer"}]},{"name":"RemoveSubjectFromGroup","parameters":[{"name":"subjectAddress","type":"Hash160"},{"name":"namespace","type":"String"},{"name":"groupID","type":"Integer"}]},{"name":"DeleteGroup","parameters":[{"name":"namespace","type":"String"},{"name":"groupID","type":"Integer"}]}]},"features":{},"groups":[],"permissions":[{"contract":"*","methods":["update"]}],"supportedstandards":[],"trusts":[],"extra":null} \ No newline at end of file diff --git a/tests/testdata/migration/0.19.2/frostfsid/frostfsid_contract.nef b/tests/testdata/migration/0.19.2/frostfsid/frostfsid_contract.nef new file mode 100755 index 0000000000000000000000000000000000000000..e952f07abbb43e33f8d36b742d22c380d3c8513d GIT binary patch literal 6214 zcmc&&YmD4h6}D&gF}v%{j&~-HHfiIXP9`fv)s)WdCR-3QY+h_cI$e!i`;x*Z=y?w%=YnQ?}pO zJ=|0q&kh*8E*505&eIf4ykGjLZ#YjyI>&N<}nHo~J09 zzIpDWslD&!Ke6q^D<@xl?rLe`(#_?*s#YqPe3+s}f_51y@g4hYe!uz*drWvdRv1KQ z$G`c9*MA}F1G=d3mD2qW?!cB%)XnLQGd-c~4?mb|Xx8+VY_jKSc3zA&n#s?>|I^K6 z@9z>ld!kf)JjINON>SByzG!kXugsYOryk+dn!@W`p;Xd&!?tm|0R9aqMKA+moBveJV z0Tq%HT(O{VZv1_yChKSlq&3SH@)IG7xibJwcL_lf{K?D=k#Gy>VV0t7A2(`joMSe( zVysnXWwFRfyiLMAX=j&y@U76ih)@ioDU>^mH>75AGqb^{&X#e86l9$*lx&W-M8h;D zZ8Q#ROhIPz+1Gab>gj4Fdn$7MRB8h=f;SKiPAwLznh1y{-m=ggAiN+b-5aDfF)^i3 z;SH@&5B21BTH)R$I-N|=*NoEgS zmI1=5AXNx}c5d{-0yCT~l?XHkcpD<)f-~TQ6B_v+f^!v+4*&<}LpwM+Ur`qvc-&I6 z&~aF}CQyc|(FMgphP1%vQ`_KCY1lcW{R@{UTOp`9ua~OIsfEN+#RIU`FGy;C8-%q8 z6aAuNUkgSx;^EjzvKNL|fun`a1MES_K-9fb42-%V#Tuq9#SUGToN$XI+=6s*`q0v! zr%X7yY`!c zD0^7f^RWw6hH066;7b(`<~~1N^USJXp878gw*QDBZZ{Dss>+P)=4IaRH*H4tlX)Yc zpAN0c$kPynAXLMdwsJS3rYzx#_w#xSJjxAdK~-2^6#y(ersPv*qKW$veh{S5hLuN; zfIavpLx?rNQh{v<(Z+_w+Mqg^ zndxf>ZfyJxCf*t{xZAnpYtjSlX$VRHXvuYLLC;v|#~=osuoH#ULmd!QE9lF&qb<>s zcsZ!QWM)DkXc=i1$Q7XqAKhGD&dh{EHbb4n_=w5^5aAN1>KvZro)^$ne;>Rvo?ii- ztc^u6v_V2hoWl@$jY*0?mZD38!5F~+Z}ACl#1hJ4v5Q7m;j*}FU7CRVphH9a-V&z0 zh2Sskpca< z*3S&Nk==(YSnYR5hJ#;7|l7*tnMcvDMe( zwT>OcmS-Vx*J4YIP!-@^*`5Xd{LU8o+(#tz-kU3?cK39!bt8nFc1ySPj27vXmf9lM5)xeqZ9 zdgX)X2EMAn2g<@iL6i%#vR^{QDqIaJW?L2E>#RE29^AVI0Q&C1wObers$<(MFs`0Y z|H-n+tlkgg*b!hm1cp6<^wuubzwT7s6SCPhzgh6*q$knkcMLoQGN4;R*(C!R(P<%s zQNY*nT};~T8LM}nwj3I)3HXkZqFY224h6k?;L_?iybf7uhCJKw3|ZtZV(0=%Ao5kf z(zKQ4J#8KhYtsf7q3La!;ORq2@Ea?I*Be`}iJ~o@qPfnEuvuURd8r8#J(R0rU55$~ zNngDi+)i%RHhE4K;ii6allY@2bPwzD@r?Aa^2>h%j^$(= literal 0 HcmV?d00001 diff --git a/tests/testdata/migration/0.21.1/frostfsid/config.json b/tests/testdata/migration/0.21.1/frostfsid/config.json new file mode 100755 index 0000000..4e42b82 --- /dev/null +++ b/tests/testdata/migration/0.21.1/frostfsid/config.json @@ -0,0 +1 @@ +{"name":"Identity","abi":{"methods":[{"name":"_deploy","offset":0,"parameters":[{"name":"data","type":"Any"},{"name":"isUpdate","type":"Boolean"}],"returntype":"Void","safe":false},{"name":"addSubjectKey","offset":1157,"parameters":[{"name":"addr","type":"Hash160"},{"name":"key","type":"PublicKey"}],"returntype":"Void","safe":false},{"name":"addSubjectToGroup","offset":4819,"parameters":[{"name":"addr","type":"Hash160"},{"name":"groupID","type":"Integer"}],"returntype":"Void","safe":false},{"name":"clearAdmin","offset":614,"parameters":[],"returntype":"Void","safe":false},{"name":"createGroup","offset":3846,"parameters":[{"name":"ns","type":"String"},{"name":"group","type":"String"}],"returntype":"Integer","safe":false},{"name":"createNamespace","offset":3452,"parameters":[{"name":"ns","type":"String"}],"returntype":"Void","safe":false},{"name":"createSubject","offset":780,"parameters":[{"name":"ns","type":"String"},{"name":"key","type":"PublicKey"}],"returntype":"Void","safe":false},{"name":"deleteGroup","offset":5444,"parameters":[{"name":"ns","type":"String"},{"name":"groupID","type":"Integer"}],"returntype":"Void","safe":false},{"name":"deleteGroupKV","offset":4670,"parameters":[{"name":"ns","type":"String"},{"name":"groupID","type":"Integer"},{"name":"key","type":"String"}],"returntype":"Void","safe":false},{"name":"deleteSubject","offset":2368,"parameters":[{"name":"addr","type":"Hash160"}],"returntype":"Void","safe":false},{"name":"deleteSubjectKV","offset":2203,"parameters":[{"name":"addr","type":"Hash160"},{"name":"key","type":"String"}],"returntype":"Void","safe":false},{"name":"getAdmin","offset":654,"parameters":[],"returntype":"Hash160","safe":true},{"name":"getGroup","offset":4040,"parameters":[{"name":"ns","type":"String"},{"name":"groupID","type":"Integer"}],"returntype":"Array","safe":true},{"name":"getGroupByName","offset":4321,"parameters":[{"name":"ns","type":"String"},{"name":"name","type":"String"}],"returntype":"Array","safe":true},{"name":"getGroupExtended","offset":4108,"parameters":[{"name":"ns","type":"String"},{"name":"groupID","type":"Integer"}],"returntype":"Array","safe":true},{"name":"getGroupIDByName","offset":4232,"parameters":[{"name":"ns","type":"String"},{"name":"name","type":"String"}],"returntype":"Integer","safe":true},{"name":"getNamespace","offset":3568,"parameters":[{"name":"ns","type":"String"}],"returntype":"Array","safe":true},{"name":"getNamespaceExtended","offset":3638,"parameters":[{"name":"ns","type":"String"}],"returntype":"Array","safe":true},{"name":"getSubject","offset":2593,"parameters":[{"name":"addr","type":"Hash160"}],"returntype":"Array","safe":true},{"name":"getSubjectByKey","offset":2942,"parameters":[{"name":"key","type":"PublicKey"}],"returntype":"Array","safe":true},{"name":"getSubjectByName","offset":3174,"parameters":[{"name":"ns","type":"String"},{"name":"name","type":"String"}],"returntype":"Array","safe":true},{"name":"getSubjectExtended","offset":2738,"parameters":[{"name":"addr","type":"Hash160"}],"returntype":"Array","safe":true},{"name":"getSubjectKV","offset":3281,"parameters":[{"name":"addr","type":"Hash160"},{"name":"name","type":"String"}],"returntype":"String","safe":true},{"name":"getSubjectKeyByName","offset":3197,"parameters":[{"name":"ns","type":"String"},{"name":"name","type":"String"}],"returntype":"PublicKey","safe":true},{"name":"listGroupSubjects","offset":5416,"parameters":[{"name":"ns","type":"String"},{"name":"groupID","type":"Integer"}],"returntype":"InteropInterface","safe":true},{"name":"listGroups","offset":4793,"parameters":[{"name":"ns","type":"String"}],"returntype":"InteropInterface","safe":true},{"name":"listNamespaceSubjects","offset":3820,"parameters":[{"name":"ns","type":"String"}],"returntype":"InteropInterface","safe":true},{"name":"listNamespaces","offset":3792,"parameters":[],"returntype":"InteropInterface","safe":true},{"name":"listSubjects","offset":3424,"parameters":[],"returntype":"InteropInterface","safe":true},{"name":"removeSubjectFromGroup","offset":5120,"parameters":[{"name":"addr","type":"Hash160"},{"name":"groupID","type":"Integer"}],"returntype":"Void","safe":false},{"name":"removeSubjectKey","offset":1494,"parameters":[{"name":"addr","type":"Hash160"},{"name":"key","type":"PublicKey"}],"returntype":"Void","safe":false},{"name":"setAdmin","offset":573,"parameters":[{"name":"addr","type":"Hash160"}],"returntype":"Void","safe":false},{"name":"setGroupKV","offset":4535,"parameters":[{"name":"ns","type":"String"},{"name":"groupID","type":"Integer"},{"name":"key","type":"String"},{"name":"val","type":"String"}],"returntype":"Void","safe":false},{"name":"setGroupName","offset":4395,"parameters":[{"name":"ns","type":"String"},{"name":"groupID","type":"Integer"},{"name":"name","type":"String"}],"returntype":"Void","safe":false},{"name":"setSubjectKV","offset":2026,"parameters":[{"name":"addr","type":"Hash160"},{"name":"key","type":"String"},{"name":"val","type":"String"}],"returntype":"Void","safe":false},{"name":"setSubjectName","offset":1844,"parameters":[{"name":"addr","type":"Hash160"},{"name":"name","type":"String"}],"returntype":"Void","safe":false},{"name":"update","offset":680,"parameters":[{"name":"script","type":"ByteArray"},{"name":"manifest","type":"ByteArray"},{"name":"data","type":"Any"}],"returntype":"Void","safe":false},{"name":"version","offset":776,"parameters":[],"returntype":"Integer","safe":true}],"events":[{"name":"CreateSubject","parameters":[{"name":"subjectAddress","type":"Hash160"}]},{"name":"AddSubjectKey","parameters":[{"name":"subjectAddress","type":"Hash160"},{"name":"subjectKey","type":"PublicKey"}]},{"name":"RemoveSubjectKey","parameters":[{"name":"subjectAddress","type":"Hash160"},{"name":"subjectKey","type":"PublicKey"}]},{"name":"SetSubjectName","parameters":[{"name":"subjectAddress","type":"Hash160"},{"name":"name","type":"String"}]},{"name":"SetSubjectKV","parameters":[{"name":"subjectAddress","type":"Hash160"},{"name":"key","type":"String"},{"name":"value","type":"String"}]},{"name":"DeleteSubjectKV","parameters":[{"name":"subjectAddress","type":"Hash160"},{"name":"key","type":"String"}]},{"name":"DeleteSubject","parameters":[{"name":"subjectAddress","type":"Hash160"}]},{"name":"CreateNamespace","parameters":[{"name":"namespace","type":"String"}]},{"name":"AddSubjectToNamespace","parameters":[{"name":"subjectAddress","type":"Hash160"},{"name":"namespace","type":"String"}]},{"name":"RemoveSubjectFromNamespace","parameters":[{"name":"subjectAddress","type":"Hash160"},{"name":"namespace","type":"String"}]},{"name":"CreateGroup","parameters":[{"name":"namespace","type":"String"},{"name":"group","type":"String"}]},{"name":"SetGroupName","parameters":[{"name":"namespace","type":"String"},{"name":"groupID","type":"Integer"},{"name":"name","type":"String"}]},{"name":"SetGroupKV","parameters":[{"name":"namespace","type":"String"},{"name":"groupID","type":"Integer"},{"name":"key","type":"String"},{"name":"value","type":"String"}]},{"name":"DeleteGroupKV","parameters":[{"name":"namespace","type":"String"},{"name":"groupID","type":"Integer"},{"name":"key","type":"String"}]},{"name":"AddSubjectToGroup","parameters":[{"name":"subjectAddress","type":"Hash160"},{"name":"namespace","type":"String"},{"name":"groupID","type":"Integer"}]},{"name":"RemoveSubjectFromGroup","parameters":[{"name":"subjectAddress","type":"Hash160"},{"name":"namespace","type":"String"},{"name":"groupID","type":"Integer"}]},{"name":"DeleteGroup","parameters":[{"name":"namespace","type":"String"},{"name":"groupID","type":"Integer"}]}]},"features":{},"groups":[],"permissions":[{"contract":"*","methods":["update"]}],"supportedstandards":[],"trusts":[],"extra":null} \ No newline at end of file diff --git a/tests/testdata/migration/0.21.1/frostfsid/frostfsid_contract.nef b/tests/testdata/migration/0.21.1/frostfsid/frostfsid_contract.nef new file mode 100755 index 0000000000000000000000000000000000000000..5250178673be52302ae9843557dd9439496efc69 GIT binary patch literal 6918 zcmc&(eQX=$89&=e?If4hUoD})dNrw=p)m^hD1=SeD+QJgAtc=Rnmgb5&hee& zJ2UN{p^d2}zpnk-U*F#K>lcnytk-WG z?`Z8O$I5~()TNRlwS)i@VEkl8`XoM@J(GQQ>WjB-9)9tG6T?q^a7@p>&&~`;K^DqBP1M zpZeDCUi-OHAE`?P#C_K8 z3G5&;xmY3h>YiUbS|8CXxy8tPi|I&2PYtF1A)nm+F-#B{JxL{;?{~k3rr-Be#XZgNtFyIkIK1~w{CtoTV#TW z+Y~UGvgqs4Y%##>4Kg(`lFx+j0TON?|)UeixEX@FX6XMH&?__#6o6=OpLTqUb1EUg8RKOJWntBV`6bBbdx@(Q5VID~8> zsYGjG+Om^!UgDomGE7~p^ck`SNIIv@&NgZi5KX-)@%xZ6J$e6m_Ok<0+#!oAArhifnaCJTEh)sGUk}Ib*UNAB2JE0+!QsXJpX;7Z&cJq z*+77X$_aV5!X%oPvE}9%JH8LD8$!WBLL1BHeh|<~*2&y~v*%>#l(!s-C(c6E`DMgLcT z0;e;GRu@eg|9YiElBpM`x=_^?2vWeE)Vaw&iiNr;_u)ep`r=dZ@G-_3(FIlMYuLN+ zQEgj!{=-j5e~48nfcE2+hPt?rTB$0)QXvT(7G*8$py?DX|98Zy8A0!*#@W!0u+iIX zt9#HLanTKT)Agy%8$j3OPaqh6c)@MAJ9uf)iD4=%Jv36YAAAFwrB8BX`}X3tZ#?_i&T{T&>==CUgOo#ZWYs=yBsWYL?^O8PwXTFFr0Q}^SXJ-bc*St#{$Z5lj-e;m9} zm-$D|B6F@%$QH)}CNGoWZf`d~Ru|)K{-00>t*7wPkg5rXQW}aqN_T$~lv1%NCGAlQ zvI-zXAlQsZr0@xeq~8%n*qJ;at9iZ#ZOsu$L*Wk!q%k?>>RO}LGb<~!@n~VMVXf3J z{W@%|h{?8?Xv0!5))u4fZA;BjZ8Tf#19#`tg>2FrcBF$kRD0S5_Nxe;53rM)dr~GV znsy@OGdBQ`D?iN&zwVPQ27_#%L_vXP!~0prI#M%53hun*@RX?3i){96y3m|5F)&L) z-ocYjuCA?Ri=m*!GDiuPlDdEcQkm209HAku$LQ*J`FlV{g-_4S7B}?}-gEE=7gl!6 z7uNJJ%k&i^S{QJ^L%f;!?aa&30|&0!9>4WKd&WrKnr}B0>u5ThT;5;JE~ehZDL{=1!x3HGK~5nYeg`quN-qDP~0w4GQoO#VVBLC+dsz~h+UvB${dPQ7pP*Fwgo zuIr@YL@G|Cls>#wiuc7%H$X;rt$t_3M!FjbkAS|u3Cy1)V(plQq z5-8{Kg5*tcocCPOoj5=3)a6AT&tzu+j+vI6Tmnj)p+_-Q$ZUzV5!GFx&-RkA%qE@T}$-2rwOWw#>wg9b67rj9rbhP}ewrKFa*Ih$Kl8@j5coK1kU?Rj}u^;qzZPN1)g&>2A8Q56@P&W z@OwJ#D3wib@8_}P0+jIl)ElCSu2SG1BtfK?17i-OA8;fPFx|_wn%J3)i?naqcYf(m zmS25mZ4Ix3*Lk2TA*+?=9}6-JX{PqR7XJ-=1fRPHFS;pHNb2;ichb4Yr8^js(kk#D zK(b-db4#j2c&3$TlZhM3T1eSMJI~L#d-Txmd8w1$Vv3e~!<@QB!uveGdWM|(uV=4u z%ZJPja&1OtaA~0=DWyY7w}fUJxWiVBo+=_&i!Hi6+y2}A0-k~l)J?JC@P@2pmlS0b z_;%_#Hskb+jk_Ok4h%Js+!r$ekEl}CZyv$ppqXL2rvNzSE?Rd+5Q%ia%m}VFmxlFd z!=-d)S50*F@sscy%gEykyvJ10#jc_`nn%5ga5!~-BdCdchX~z-wKkv1<)T(y(ESTckv_vIULr93MLWu3bg km%#X~Ly_=v(e#A$lK9QP0T^aki~s-t literal 0 HcmV?d00001 diff --git a/tests/util.go b/tests/util.go index ed7c119..617528a 100644 --- a/tests/util.go +++ b/tests/util.go @@ -7,6 +7,7 @@ import ( "testing" "time" + json "github.com/nspcc-dev/go-ordered-json" "github.com/nspcc-dev/neo-go/pkg/config" "github.com/nspcc-dev/neo-go/pkg/consensus" "github.com/nspcc-dev/neo-go/pkg/core" @@ -20,6 +21,8 @@ import ( "github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/services/rpcsrv" "github.com/nspcc-dev/neo-go/pkg/services/stateroot" + "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" + "github.com/nspcc-dev/neo-go/pkg/smartcontract/nef" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" @@ -226,3 +229,56 @@ func runRPC(ctx context.Context, t *testing.T, chain *core.Blockchain, walletPat } } } + +func loadCompiledContract(t testing.TB, sender util.Uint160, nefPath, manifestPath string) *neotest.Contract { + nefBytes, err := os.ReadFile(nefPath) + require.NoError(t, err) + + f, err := nef.FileFromBytes(nefBytes) + require.NoError(t, err) + + manifestBytes, err := os.ReadFile(manifestPath) + require.NoError(t, err) + + m := new(manifest.Manifest) + err = json.Unmarshal(manifestBytes, m) + require.NoError(t, err) + + hash := state.CreateContractHash(sender, f.Checksum, m.Name) + + return &neotest.Contract{ + Hash: hash, + NEF: &f, + Manifest: m, + } +} + +const contractPathFormat = "testdata/migration/%s/%s/%s_contract.nef" +const manifestPathFormat = "testdata/migration/%s/%s/config.json" + +const v0_19_2 = "0.19.2" +const v0_21_1 = "0.21.1" + +func updateContract(t testing.TB, c *neotest.Contract, e *neotest.Executor, contractHash util.Uint160, data any) { + neb, err := c.NEF.Bytes() + require.NoError(t, err) + + rawManifest, err := json.Marshal(c.Manifest) + require.NoError(t, err) + + inv := e.NewInvoker(contractHash, e.Committee) + + inv.Invoke(t, nil, "update", neb, rawManifest, data) +} + +func updateContractFail(t testing.TB, c *neotest.Contract, e *neotest.Executor, contractHash util.Uint160, data any, faultException string) { + neb, err := c.NEF.Bytes() + require.NoError(t, err) + + rawManifest, err := json.Marshal(c.Manifest) + require.NoError(t, err) + + inv := e.NewInvoker(contractHash, e.Committee) + + inv.InvokeFail(t, faultException, "update", neb, rawManifest, data) +}