File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed
platform-test-suite/test/functional/platform
rs-dapi/src/services/platform_service Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,31 @@ describe('Platform', () => {
5959 expect ( broadcastError . getCause ( ) ) . to . be . an . instanceOf ( IdentityNotFoundError ) ;
6060 } ) ;
6161
62+ it ( 'should expose validation error when document property positions are not contiguous' , async ( ) => {
63+ // Additional wait time to mitigate testnet latency
64+ await waitForSTPropagated ( ) ;
65+
66+ const identityNonce = await client . platform . nonceManager
67+ . bumpIdentityNonce ( identity . getId ( ) ) ;
68+ const invalidDataContract = await getDataContractFixture ( identityNonce , identity . getId ( ) ) ;
69+
70+ const documentSchema = invalidDataContract . getDocumentSchema ( 'niceDocument' ) ;
71+ documentSchema . properties . name . position = 5 ;
72+ invalidDataContract . setDocumentSchema ( 'niceDocument' , documentSchema , { skipValidation : true } ) ;
73+
74+ let broadcastError ;
75+
76+ try {
77+ await client . platform . contracts . publish ( invalidDataContract , identity ) ;
78+ } catch ( e ) {
79+ broadcastError = e ;
80+ }
81+
82+ expect ( broadcastError ) . to . be . an . instanceOf ( StateTransitionBroadcastError ) ;
83+ expect ( broadcastError . getCode ( ) ) . to . equal ( 10411 ) ;
84+ expect ( broadcastError . getMessage ( ) ) . to . equal ( 'position field is not present for document type "niceDocument"' ) ;
85+ } ) ;
86+
6287 it ( 'should create new data contract with previously created identity as an owner' , async ( ) => {
6388 // Additional wait time to mitigate testnet latency
6489 await waitForSTPropagated ( ) ;
Original file line number Diff line number Diff line change @@ -149,9 +149,25 @@ impl From<TenderdashStatus> for tonic::Response<WaitForStateTransitionResultResp
149149
150150impl From < TenderdashStatus > for StateTransitionBroadcastError {
151151 fn from ( err : TenderdashStatus ) -> Self {
152+ let message = if let Some ( msg) = err. message {
153+ msg
154+ } else {
155+ // try to extract from consensus error
156+ if let Some ( consensus_error_bytes) = & err. consensus_error
157+ && let Ok ( consensus_error) =
158+ ConsensusError :: deserialize_from_bytes ( consensus_error_bytes) . inspect_err ( |e| {
159+ tracing:: debug!( "Failed to deserialize consensus error: {}" , e) ;
160+ } )
161+ {
162+ consensus_error. to_string ( )
163+ } else {
164+ "Unknown error" . to_string ( )
165+ }
166+ } ;
167+
152168 StateTransitionBroadcastError {
153169 code : err. code . clamp ( 0 , u32:: MAX as i64 ) as u32 ,
154- message : err . message . unwrap_or_else ( || "Unknown error" . to_string ( ) ) ,
170+ message,
155171 data : err. consensus_error . clone ( ) . unwrap_or_default ( ) ,
156172 }
157173 }
You can’t perform that action at this time.
0 commit comments