Skip to content

Commit

Permalink
Fix schema tests
Browse files Browse the repository at this point in the history
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
  • Loading branch information
Arjentix committed Dec 4, 2023
1 parent f933434 commit b08ec9c
Showing 1 changed file with 8 additions and 40 deletions.
48 changes: 8 additions & 40 deletions schema/gen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ types!(
Box<Value>,
Box<ValuePredicate>,
BurnBox,
BurnBox,
ConfigurationEvent,
ConstString,
Container,
Expand Down Expand Up @@ -201,7 +200,6 @@ types!(
Fixed,
ForwardCursor,
GrantBox,
GrantBox,
Hash,
HashOf<MerkleTree<SignedTransaction>>,
HashOf<SignedBlock>,
Expand All @@ -226,7 +224,6 @@ types!(
MetadataChanged<DomainId>,
MetadataLimits,
MintBox,
MintBox,
Mintable,
Name,
NewAccount,
Expand All @@ -243,7 +240,6 @@ types!(
Option<Hash>,
Option<HashOf<MerkleTree<SignedTransaction>>>,
Option<HashOf<SignedBlock>>,
Option<InstructionBox>,
Option<IpfsPath>,
Option<PipelineEntityKind>,
Option<PipelineStatusKind>,
Expand Down Expand Up @@ -281,13 +277,10 @@ types!(
QueryExecutionFail,
QueryPayload,
RegisterBox,
RegisterBox,
RegistrableBox,
RemoveKeyValueBox,
RemoveKeyValueBox,
Repeats,
RevokeBox,
RevokeBox,
Role,
RoleEvent,
RoleEventFilter,
Expand All @@ -298,7 +291,6 @@ types!(
SemiInterval<u32>,
SemiRange,
SetKeyValueBox,
SetKeyValueBox,
SetParameter,
Signature,
SignatureCheckCondition,
Expand Down Expand Up @@ -326,7 +318,6 @@ types!(
TransactionRejectionReason,
TransactionValue,
TransferBox,
TransferBox,
Trigger<TriggeringFilterBox>,
TriggerCompletedEventFilter,
TriggerCompletedOutcomeType,
Expand All @@ -337,7 +328,6 @@ types!(
TriggerNumberOfExecutionsChanged,
TriggeringFilterBox,
UnregisterBox,
UnregisterBox,
UpgradableBox,
ValidationFail,
Value,
Expand Down Expand Up @@ -439,40 +429,18 @@ mod tests {
let mut missing_schemas = HashMap::<&str, _>::new();

for type_name in type_names {
if let (Some(mut start), Some(end)) = (type_name.find('<'), type_name.rfind('>')) {
start += 1;

let mut angle_bracket_diff = 0_u8;
for (i, c) in type_name[start..end].chars().enumerate() {
if c == '<' {
angle_bracket_diff += 1_u8;
}
if c == '>' {
angle_bracket_diff -= 1_u8;
}

if c == ',' && angle_bracket_diff == 0_u8 {
let generic = type_name[start..(start + i)].trim();
let (Some(start), Some(end)) = (type_name.find('<'), type_name.rfind('>')) else {
continue;
};

start += i + 1;
if !is_const_generic(generic) {
continue;
}
assert!(start < end, "Invalid type name: {}", type_name);

if !type_names.contains(generic) {
missing_schemas
.entry(type_name)
.or_insert_with(Vec::new)
.push(generic);
}
}
for generic in type_name.split(", ") {
if !is_const_generic(generic) {
continue;
}

let generic = type_name[start..end].trim();
if !generic.is_empty()
&& !is_const_generic(generic)
&& !type_names.contains(generic)
{
if !type_names.contains(generic) {
missing_schemas
.entry(type_name)
.or_insert_with(Vec::new)
Expand Down

0 comments on commit b08ec9c

Please sign in to comment.