/*
Copyright IBM Corp. 2017 All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

                 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

syntax = "proto3";

option go_package = "github.com/hyperledger/fabric/common/tools/protolator/testprotos";

package testprotos;

// SimpleMsg is designed to test that all three types of message fields, plain, map,
// and slice are handled by the protolator tool
message SimpleMsg {
    string plain_field = 1;
    map<string, string> map_field = 2;
    repeated string slice_field = 3;
}

// NestedMsg is designed to test the nested message component
message NestedMsg {
	SimpleMsg plain_nested_field = 1;
	map<string,SimpleMsg> map_nested_field = 2;
	repeated SimpleMsg slice_nested_field = 3;
}

// StaticallyOpaqueMsg is designed to test the statically opaque message component
// All fields are statically marshaled to the NestedMsg type
message StaticallyOpaqueMsg {
	bytes plain_opaque_field = 1;
	map<string, bytes> map_opaque_field = 2;
	repeated bytes slice_opaque_field = 3;
}

// VariablyOpaqueMsg is designed to test the staticaly opaque message component
// The opaque type is determined by opaque_type
message VariablyOpaqueMsg {
	string opaque_type = 1;
	bytes plain_opaque_field = 2;
	map<string, bytes> map_opaque_field = 3;
	repeated bytes slice_opaque_field = 4;
}

// DynamicMsg is designed to test the dynamic message component
// The dynamic wrapper applied to ContextlessMsg is determined by
// dynamic_type
message DynamicMsg {
	string dynamic_type = 1;
	ContextlessMsg plain_dynamic_field = 2;
	map<string,ContextlessMsg> map_dynamic_field = 3;
	repeated ContextlessMsg slice_dynamic_field = 4;
}

// ContextlessMsg is designed to carry a message of completely arbitrary type
// Because there is no context for the type embedded in the message, the opaque
// type must be dynamically added at runtime
message ContextlessMsg {
	bytes opaque_field = 1;
}

// UnmarshalableDeepFields contains fields which are defined to be opaque, but will
// return an error if they are asked to be deserialized.
message UnmarshalableDeepFields {
	bytes plain_opaque_field = 1;
	map<string,bytes> map_opaque_field = 2;
	repeated bytes slice_opaque_field = 3;
}
