@@ -4209,6 +4209,73 @@ struct XChain_test : public beast::unit_test::suite,
4209
4209
}
4210
4210
}
4211
4211
4212
+ void
4213
+ testBadPublicKey ()
4214
+ {
4215
+ using namespace jtx ;
4216
+
4217
+ testcase (" Bad attestations" );
4218
+ {
4219
+ // Create a bridge and add an attestation with a bad public key
4220
+ XEnv scEnv (*this , true );
4221
+ std::uint32_t const claimID = 1 ;
4222
+ std::optional<Account> dst{scBob};
4223
+ auto const amt = XRP (1000 );
4224
+ scEnv.tx (create_bridge (Account::master, jvb))
4225
+ .tx (jtx::signers (Account::master, quorum, signers))
4226
+ .close ();
4227
+ scEnv.tx (xchain_create_claim_id (scAlice, jvb, reward, mcAlice))
4228
+ .close ();
4229
+ auto jvAtt = claim_attestation (
4230
+ scAttester,
4231
+ jvb,
4232
+ mcAlice,
4233
+ amt,
4234
+ payees[UT_XCHAIN_DEFAULT_QUORUM],
4235
+ true ,
4236
+ claimID,
4237
+ dst,
4238
+ signers[UT_XCHAIN_DEFAULT_QUORUM]);
4239
+ {
4240
+ // Change to an invalid keytype
4241
+ auto k = jvAtt[" PublicKey" ].asString ();
4242
+ k.at (1 ) = ' 9' ;
4243
+ jvAtt[" PublicKey" ] = k;
4244
+ }
4245
+ scEnv.tx (jvAtt, ter (temMALFORMED)).close ();
4246
+ }
4247
+ {
4248
+ // Create a bridge and add an create account attestation with a bad
4249
+ // public key
4250
+ XEnv scEnv (*this , true );
4251
+ std::uint32_t const createCount = 1 ;
4252
+ Account dst{scBob};
4253
+ auto const amt = XRP (1000 );
4254
+ auto const rewardAmt = XRP (1 );
4255
+ scEnv.tx (create_bridge (Account::master, jvb))
4256
+ .tx (jtx::signers (Account::master, quorum, signers))
4257
+ .close ();
4258
+ auto jvAtt = create_account_attestation (
4259
+ scAttester,
4260
+ jvb,
4261
+ mcAlice,
4262
+ amt,
4263
+ rewardAmt,
4264
+ payees[UT_XCHAIN_DEFAULT_QUORUM],
4265
+ true ,
4266
+ createCount,
4267
+ dst,
4268
+ signers[UT_XCHAIN_DEFAULT_QUORUM]);
4269
+ {
4270
+ // Change to an invalid keytype
4271
+ auto k = jvAtt[" PublicKey" ].asString ();
4272
+ k.at (1 ) = ' 9' ;
4273
+ jvAtt[" PublicKey" ] = k;
4274
+ }
4275
+ scEnv.tx (jvAtt, ter (temMALFORMED)).close ();
4276
+ }
4277
+ }
4278
+
4212
4279
void
4213
4280
run () override
4214
4281
{
@@ -4226,6 +4293,7 @@ struct XChain_test : public beast::unit_test::suite,
4226
4293
testXChainCreateAccount ();
4227
4294
testFeeDipsIntoReserve ();
4228
4295
testXChainDeleteDoor ();
4296
+ testBadPublicKey ();
4229
4297
}
4230
4298
};
4231
4299
0 commit comments