@@ -157,4 +157,33 @@ describe('encode and decode using new types as a parameter', function () {
157
157
const decoded = decode ( encoded , newDefs )
158
158
expect ( decoded ) . toEqual ( tx )
159
159
} )
160
+
161
+ it ( 'removing PermissionValue does not break encoding/decoding' , function ( ) {
162
+ // Make a deep copy of definitions
163
+ const definitions = JSON . parse ( JSON . stringify ( normalDefinitionsJson ) )
164
+
165
+ const originalFieldsLength = definitions . FIELDS . length
166
+
167
+ // Remove PermissionValue from definitions
168
+ if ( definitions . FIELDS ) {
169
+ definitions . FIELDS = definitions . FIELDS . filter (
170
+ ( fieldTuple : [ string , object ] ) => fieldTuple [ 0 ] !== 'PermissionValue' ,
171
+ )
172
+ }
173
+
174
+ // Verify it was deleted
175
+ const expectedFieldsLength = originalFieldsLength - 1
176
+ expect ( definitions . FIELDS . length ) . toBe ( expectedFieldsLength )
177
+
178
+ // Create new custom definitions
179
+ const customDefs = new XrplDefinitions ( definitions )
180
+
181
+ const tx = { ...txJson }
182
+
183
+ // It should encode and decode normally, even with PermissionValue missing
184
+ const encoded = encode ( tx , customDefs )
185
+ const decoded = decode ( encoded , customDefs )
186
+
187
+ expect ( decoded ) . toEqual ( tx )
188
+ } )
160
189
} )
0 commit comments