Skip to content

Commit 9a9751a

Browse files
committed
fix: using data to calculate capacity
1 parent 1945c43 commit 9a9751a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/ckb/types/output.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def capacity=(value)
3434
end
3535

3636
def calculate_bytesize
37-
bytesize = 8 + Utils.hex_to_bin(@data_hash).bytesize + @lock.calculate_bytesize
37+
raise "Don't know data" if @data.nil?
38+
bytesize = 8 + Utils.hex_to_bin(@data).bytesize + @lock.calculate_bytesize
3839
bytesize += @type.calculate_bytesize if @type
3940
bytesize
4041
end

spec/ckb/types/output_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
it "default" do
1414
expect(
1515
output.calculate_bytesize
16-
).to eq 93
16+
).to eq 61
1717
end
1818

1919
it "with data" do
2020
output.instance_variable_set(:@data, "0x1234")
2121
expect(
2222
output.calculate_bytesize
23-
).to eq 93
23+
).to eq 63
2424
end
2525

2626
it "with type script" do
@@ -32,13 +32,13 @@
3232

3333
expect(
3434
output.calculate_bytesize
35-
).to eq (93 + 33)
35+
).to eq (61 + 33)
3636
end
3737
end
3838

3939
it "calculate min capacity" do
4040
expect(
4141
output.calculate_min_capacity
42-
).to eq CKB::Utils.byte_to_shannon(93)
42+
).to eq CKB::Utils.byte_to_shannon(61)
4343
end
4444
end

0 commit comments

Comments
 (0)