@@ -45,54 +45,6 @@ public void Clean()
45
45
46
46
[ TestMethod ]
47
47
public void TestSetAndGet ( )
48
- {
49
- var snapshot1 = _snapshot . CreateSnapshot ( ) ;
50
- UInt160 committeeMultiSigAddr = NativeContract . NEO . GetCommitteeAddress ( snapshot1 ) ;
51
- ECPoint [ ] validators = NativeContract . NEO . ComputeNextBlockValidators ( snapshot1 , TestProtocolSettings . Default ) ;
52
- List < NotifyEventArgs > notifications = new List < NotifyEventArgs > ( ) ;
53
- EventHandler < NotifyEventArgs > ev = ( o , e ) => notifications . Add ( e ) ;
54
- ApplicationEngine . Notify += ev ;
55
- var ret = NativeContract . RoleManagement . Call (
56
- snapshot1 ,
57
- new Nep17NativeContractExtensions . ManualWitness ( committeeMultiSigAddr ) ,
58
- new Block { Header = new Header ( ) } ,
59
- "designateAsRole" ,
60
- new ContractParameter ( ContractParameterType . Integer ) { Value = new BigInteger ( ( int ) Role . StateValidator ) } ,
61
- new ContractParameter ( ContractParameterType . Array ) { Value = validators . Select ( p => new ContractParameter ( ContractParameterType . ByteArray ) { Value = p . ToArray ( ) } ) . ToList ( ) }
62
- ) ;
63
- snapshot1 . Commit ( ) ;
64
- ApplicationEngine . Notify -= ev ;
65
- notifications . Count . Should ( ) . Be ( 1 ) ;
66
- notifications [ 0 ] . EventName . Should ( ) . Be ( "Designation" ) ;
67
- var snapshot2 = _snapshot . CreateSnapshot ( ) ;
68
- ret = NativeContract . RoleManagement . Call (
69
- snapshot2 ,
70
- "getDesignatedByRole" ,
71
- new ContractParameter ( ContractParameterType . Integer ) { Value = new BigInteger ( ( int ) Role . StateValidator ) } ,
72
- new ContractParameter ( ContractParameterType . Integer ) { Value = new BigInteger ( 1u ) }
73
- ) ;
74
- ret . Should ( ) . BeOfType < VM . Types . Array > ( ) ;
75
- ( ret as VM . Types . Array ) . Count . Should ( ) . Be ( 7 ) ;
76
- ( ret as VM . Types . Array ) [ 0 ] . GetSpan ( ) . ToHexString ( ) . Should ( ) . Be ( validators [ 0 ] . ToArray ( ) . ToHexString ( ) ) ;
77
- ( ret as VM . Types . Array ) [ 1 ] . GetSpan ( ) . ToHexString ( ) . Should ( ) . Be ( validators [ 1 ] . ToArray ( ) . ToHexString ( ) ) ;
78
- ( ret as VM . Types . Array ) [ 2 ] . GetSpan ( ) . ToHexString ( ) . Should ( ) . Be ( validators [ 2 ] . ToArray ( ) . ToHexString ( ) ) ;
79
- ( ret as VM . Types . Array ) [ 3 ] . GetSpan ( ) . ToHexString ( ) . Should ( ) . Be ( validators [ 3 ] . ToArray ( ) . ToHexString ( ) ) ;
80
- ( ret as VM . Types . Array ) [ 4 ] . GetSpan ( ) . ToHexString ( ) . Should ( ) . Be ( validators [ 4 ] . ToArray ( ) . ToHexString ( ) ) ;
81
- ( ret as VM . Types . Array ) [ 5 ] . GetSpan ( ) . ToHexString ( ) . Should ( ) . Be ( validators [ 5 ] . ToArray ( ) . ToHexString ( ) ) ;
82
- ( ret as VM . Types . Array ) [ 6 ] . GetSpan ( ) . ToHexString ( ) . Should ( ) . Be ( validators [ 6 ] . ToArray ( ) . ToHexString ( ) ) ;
83
-
84
- ret = NativeContract . RoleManagement . Call (
85
- snapshot2 ,
86
- "getDesignatedByRole" ,
87
- new ContractParameter ( ContractParameterType . Integer ) { Value = new BigInteger ( ( int ) Role . StateValidator ) } ,
88
- new ContractParameter ( ContractParameterType . Integer ) { Value = new BigInteger ( 0 ) }
89
- ) ;
90
- ret . Should ( ) . BeOfType < VM . Types . Array > ( ) ;
91
- ( ret as VM . Types . Array ) . Count . Should ( ) . Be ( 0 ) ;
92
- }
93
-
94
- [ TestMethod ]
95
- public void TestDesignateP2PNotary ( )
96
48
{
97
49
byte [ ] privateKey1 = new byte [ 32 ] ;
98
50
var rng1 = System . Security . Cryptography . RandomNumberGenerator . Create ( ) ;
@@ -107,43 +59,47 @@ public void TestDesignateP2PNotary()
107
59
publicKeys [ 1 ] = key2 . PublicKey ;
108
60
publicKeys = publicKeys . OrderBy ( p => p ) . ToArray ( ) ;
109
61
110
- var snapshot1 = _snapshot . CreateSnapshot ( ) ;
111
- UInt160 committeeMultiSigAddr = NativeContract . NEO . GetCommitteeAddress ( snapshot1 ) ;
112
- List < NotifyEventArgs > notifications = new List < NotifyEventArgs > ( ) ;
113
- EventHandler < NotifyEventArgs > ev = ( o , e ) => notifications . Add ( e ) ;
114
- ApplicationEngine . Notify += ev ;
115
- var ret = NativeContract . RoleManagement . Call (
116
- snapshot1 ,
117
- new Nep17NativeContractExtensions . ManualWitness ( committeeMultiSigAddr ) ,
118
- new Block { Header = new Header ( ) } ,
119
- "designateAsRole" ,
120
- new ContractParameter ( ContractParameterType . Integer ) { Value = new BigInteger ( ( int ) Role . P2PNotary ) } ,
121
- new ContractParameter ( ContractParameterType . Array ) { Value = publicKeys . Select ( p => new ContractParameter ( ContractParameterType . ByteArray ) { Value = p . ToArray ( ) } ) . ToList ( ) }
122
- ) ;
123
- snapshot1 . Commit ( ) ;
124
- ApplicationEngine . Notify -= ev ;
125
- notifications . Count . Should ( ) . Be ( 1 ) ;
126
- notifications [ 0 ] . EventName . Should ( ) . Be ( "Designation" ) ;
127
- var snapshot2 = _snapshot . CreateSnapshot ( ) ;
128
- ret = NativeContract . RoleManagement . Call (
129
- snapshot2 ,
130
- "getDesignatedByRole" ,
131
- new ContractParameter ( ContractParameterType . Integer ) { Value = new BigInteger ( ( int ) Role . P2PNotary ) } ,
132
- new ContractParameter ( ContractParameterType . Integer ) { Value = new BigInteger ( 1u ) }
133
- ) ;
134
- ret . Should ( ) . BeOfType < VM . Types . Array > ( ) ;
135
- ( ret as VM . Types . Array ) . Count . Should ( ) . Be ( 2 ) ;
136
- ( ret as VM . Types . Array ) [ 0 ] . GetSpan ( ) . ToHexString ( ) . Should ( ) . Be ( publicKeys [ 0 ] . ToArray ( ) . ToHexString ( ) ) ;
137
- ( ret as VM . Types . Array ) [ 1 ] . GetSpan ( ) . ToHexString ( ) . Should ( ) . Be ( publicKeys [ 1 ] . ToArray ( ) . ToHexString ( ) ) ;
62
+ List < Role > roles = new List < Role > ( ) { Role . StateValidator , Role . Oracle , Role . NeoFSAlphabetNode , Role . P2PNotary } ;
63
+ foreach ( var role in roles )
64
+ {
65
+ var snapshot1 = _snapshot . CreateSnapshot ( ) ;
66
+ UInt160 committeeMultiSigAddr = NativeContract . NEO . GetCommitteeAddress ( snapshot1 ) ;
67
+ List < NotifyEventArgs > notifications = new List < NotifyEventArgs > ( ) ;
68
+ EventHandler < NotifyEventArgs > ev = ( o , e ) => notifications . Add ( e ) ;
69
+ ApplicationEngine . Notify += ev ;
70
+ var ret = NativeContract . RoleManagement . Call (
71
+ snapshot1 ,
72
+ new Nep17NativeContractExtensions . ManualWitness ( committeeMultiSigAddr ) ,
73
+ new Block { Header = new Header ( ) } ,
74
+ "designateAsRole" ,
75
+ new ContractParameter ( ContractParameterType . Integer ) { Value = new BigInteger ( ( int ) role ) } ,
76
+ new ContractParameter ( ContractParameterType . Array ) { Value = publicKeys . Select ( p => new ContractParameter ( ContractParameterType . ByteArray ) { Value = p . ToArray ( ) } ) . ToList ( ) }
77
+ ) ;
78
+ snapshot1 . Commit ( ) ;
79
+ ApplicationEngine . Notify -= ev ;
80
+ notifications . Count . Should ( ) . Be ( 1 ) ;
81
+ notifications [ 0 ] . EventName . Should ( ) . Be ( "Designation" ) ;
82
+ var snapshot2 = _snapshot . CreateSnapshot ( ) ;
83
+ ret = NativeContract . RoleManagement . Call (
84
+ snapshot2 ,
85
+ "getDesignatedByRole" ,
86
+ new ContractParameter ( ContractParameterType . Integer ) { Value = new BigInteger ( ( int ) role ) } ,
87
+ new ContractParameter ( ContractParameterType . Integer ) { Value = new BigInteger ( 1u ) }
88
+ ) ;
89
+ ret . Should ( ) . BeOfType < VM . Types . Array > ( ) ;
90
+ ( ret as VM . Types . Array ) . Count . Should ( ) . Be ( 2 ) ;
91
+ ( ret as VM . Types . Array ) [ 0 ] . GetSpan ( ) . ToHexString ( ) . Should ( ) . Be ( publicKeys [ 0 ] . ToArray ( ) . ToHexString ( ) ) ;
92
+ ( ret as VM . Types . Array ) [ 1 ] . GetSpan ( ) . ToHexString ( ) . Should ( ) . Be ( publicKeys [ 1 ] . ToArray ( ) . ToHexString ( ) ) ;
138
93
139
- ret = NativeContract . RoleManagement . Call (
140
- snapshot2 ,
141
- "getDesignatedByRole" ,
142
- new ContractParameter ( ContractParameterType . Integer ) { Value = new BigInteger ( ( int ) Role . P2PNotary ) } ,
143
- new ContractParameter ( ContractParameterType . Integer ) { Value = new BigInteger ( 0 ) }
144
- ) ;
145
- ret . Should ( ) . BeOfType < VM . Types . Array > ( ) ;
146
- ( ret as VM . Types . Array ) . Count . Should ( ) . Be ( 0 ) ;
94
+ ret = NativeContract . RoleManagement . Call (
95
+ snapshot2 ,
96
+ "getDesignatedByRole" ,
97
+ new ContractParameter ( ContractParameterType . Integer ) { Value = new BigInteger ( ( int ) role ) } ,
98
+ new ContractParameter ( ContractParameterType . Integer ) { Value = new BigInteger ( 0 ) }
99
+ ) ;
100
+ ret . Should ( ) . BeOfType < VM . Types . Array > ( ) ;
101
+ ( ret as VM . Types . Array ) . Count . Should ( ) . Be ( 0 ) ;
102
+ }
147
103
}
148
104
149
105
private void ApplicationEngine_Notify ( object sender , NotifyEventArgs e )
0 commit comments