fix reference margins

This commit is contained in:
Hanashi
2026-08-10 03:15:00 -04:00
parent 865fcb8b56
commit 3fa0c3dde1
10 changed files with 1046 additions and 507 deletions
@@ -65,7 +65,6 @@ impl ArtcraftSeedance2p0CostState {
let usd_cents = seedance_2p0_four_k_usd_cents(
self.duration_seconds,
self.batch_count,
self.has_video_reference,
);
return VideoGenerationCostEstimate {
cost_in_credits: Some(usd_cents),
@@ -481,4 +480,74 @@ mod tests {
.cost_in_usd_cents
.unwrap()
}
// ── Video reference deltas ──
//
// References price on the with-reference rate card; the delta must be positive at every resolution and duration.
mod video_reference_deltas {
use enums::common::generation::common_resolution::CommonResolution;
use super::super::ArtcraftSeedance2p0CostState;
#[test]
fn refs_cost_more_at_480p() {
assert_ref_delta(CommonResolution::FourEightyP, 5, 39, 45, 6);
assert_ref_delta(CommonResolution::FourEightyP, 10, 78, 89, 11);
assert_ref_delta(CommonResolution::FourEightyP, 15, 117, 133, 16);
}
#[test]
fn refs_cost_more_at_720p() {
assert_ref_delta(CommonResolution::SevenTwentyP, 5, 80, 111, 31);
assert_ref_delta(CommonResolution::SevenTwentyP, 10, 160, 221, 61);
assert_ref_delta(CommonResolution::SevenTwentyP, 15, 240, 331, 91);
}
#[test]
fn refs_cost_more_at_1080p() {
assert_ref_delta(CommonResolution::TenEightyP, 5, 233, 256, 23);
assert_ref_delta(CommonResolution::TenEightyP, 10, 466, 511, 45);
assert_ref_delta(CommonResolution::TenEightyP, 15, 699, 767, 68);
}
#[test]
fn refs_cost_more_at_4k() {
assert_ref_delta(CommonResolution::FourK, 5, 433, 569, 136);
assert_ref_delta(CommonResolution::FourK, 10, 866, 1138, 272);
assert_ref_delta(CommonResolution::FourK, 15, 1299, 1707, 408);
}
/// Price the same generation with and without a reference video; pin
/// both prices and the delta, in USD cents AND credits (credits equal
/// cents, and both must show references costing more).
fn assert_ref_delta(
resolution: CommonResolution,
duration_seconds: u16,
expected_no_ref: u64,
expected_with_ref: u64,
expected_delta: u64,
) {
let no_ref = ArtcraftSeedance2p0CostState {
resolution, duration_seconds, batch_count: 1, has_video_reference: false,
}.estimate_cost();
let with_ref = ArtcraftSeedance2p0CostState {
resolution, duration_seconds, batch_count: 1, has_video_reference: true,
}.estimate_cost();
let no_ref_cents = no_ref.cost_in_usd_cents.unwrap();
let with_ref_cents = with_ref.cost_in_usd_cents.unwrap();
assert_eq!(no_ref_cents, expected_no_ref);
assert_eq!(with_ref_cents, expected_with_ref);
assert_eq!(with_ref_cents - no_ref_cents, expected_delta);
assert!(with_ref_cents > no_ref_cents, "references must cost more");
let no_ref_credits = no_ref.cost_in_credits.unwrap();
let with_ref_credits = with_ref.cost_in_credits.unwrap();
assert_eq!(no_ref_credits, expected_no_ref);
assert_eq!(with_ref_credits, expected_with_ref);
assert_eq!(with_ref_credits - no_ref_credits, expected_delta);
}
}
}
@@ -12,6 +12,19 @@ const CENTS_PER_SECOND_480P: f64 = 10.0;
const CENTS_PER_SECOND_720P: f64 = 25.0;
const CENTS_PER_SECOND_1080P: f64 = 50.0;
/// USD cents per second, in hundredths of a cent, when one or more
/// reference videos are attached. Held as integer hundredths so the math is
/// exact; rounded up to whole cents once, after multiplying by
/// duration × batch.
/// 480p: 10.20 ¢/s
/// 720p: 25.70 ¢/s
/// 1080p: 57.80 ¢/s
/// 4K: 113.80 ¢/s
const WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_480P: u64 = 1_020;
const WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_720P: u64 = 2_570;
const WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_1080P: u64 = 5_780;
const WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_4K: u64 = 11_380;
pub struct ArtcraftSeedance2p0BytePlusCostState {
pub resolution: CommonResolution,
pub duration_seconds: u16,
@@ -32,11 +45,23 @@ impl ArtcraftSeedance2p0BytePlusCostState {
}
pub fn estimate_cost(&self) -> VideoGenerationCostEstimate {
if self.has_video_reference {
let usd_cents = self.with_video_reference_usd_cents();
return VideoGenerationCostEstimate {
cost_in_credits: Some(usd_cents),
cost_in_usd_cents: Some(usd_cents),
is_free: false,
is_unlimited: false,
is_rate_limited: false,
has_watermark: false,
failures_are_refunded: None,
};
}
if self.resolution == CommonResolution::FourK {
let usd_cents = seedance_2p0_four_k_usd_cents(
self.duration_seconds,
self.batch_count,
self.has_video_reference,
);
return VideoGenerationCostEstimate {
cost_in_credits: Some(usd_cents),
@@ -67,6 +92,22 @@ impl ArtcraftSeedance2p0BytePlusCostState {
failures_are_refunded: None,
}
}
/// Price when one or more reference videos are attached.
fn with_video_reference_usd_cents(&self) -> u64 {
let centi_cents_per_second = match self.resolution {
CommonResolution::FourEightyP => WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_480P,
CommonResolution::TenEightyP => WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_1080P,
CommonResolution::FourK => WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_4K,
// Everything else (including 720p) prices at 720p.
_ => WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_720P,
};
let seconds = self.duration_seconds as u64 * self.batch_count as u64;
// Round up to whole cents.
(centi_cents_per_second * seconds).div_ceil(100)
}
}
#[cfg(test)]
@@ -187,10 +228,11 @@ mod tests {
#[test]
fn explicit_4k_with_video_reference() {
assert_eq!(artcraft_4k_cents(4, 1, true), 416);
assert_eq!(artcraft_4k_cents(5, 1, true), 519);
assert_eq!(artcraft_4k_cents(10, 1, true), 1038);
assert_eq!(artcraft_4k_cents(15, 1, true), 1557);
// 113.80 ¢/s with-reference card, rounded up to whole cents.
assert_eq!(artcraft_4k_cents(4, 1, true), 456);
assert_eq!(artcraft_4k_cents(5, 1, true), 569);
assert_eq!(artcraft_4k_cents(10, 1, true), 1138);
assert_eq!(artcraft_4k_cents(15, 1, true), 1707);
}
}
@@ -243,4 +285,74 @@ mod tests {
fn cost_cents(resolution: Option<RouterResolution>, duration_seconds: u16, video_batch_count: u16) -> u64 {
build_cost(resolution, duration_seconds, video_batch_count).cost_in_usd_cents.unwrap()
}
// ── Video reference deltas ──
//
// References price on the with-reference rate card (10.20/25.70/57.80/113.80 ¢/s); the delta must be positive at every resolution and duration.
mod video_reference_deltas {
use enums::common::generation::common_resolution::CommonResolution;
use super::super::ArtcraftSeedance2p0BytePlusCostState;
#[test]
fn refs_cost_more_at_480p() {
assert_ref_delta(CommonResolution::FourEightyP, 5, 50, 51, 1);
assert_ref_delta(CommonResolution::FourEightyP, 10, 100, 102, 2);
assert_ref_delta(CommonResolution::FourEightyP, 15, 150, 153, 3);
}
#[test]
fn refs_cost_more_at_720p() {
assert_ref_delta(CommonResolution::SevenTwentyP, 5, 125, 129, 4);
assert_ref_delta(CommonResolution::SevenTwentyP, 10, 250, 257, 7);
assert_ref_delta(CommonResolution::SevenTwentyP, 15, 375, 386, 11);
}
#[test]
fn refs_cost_more_at_1080p() {
assert_ref_delta(CommonResolution::TenEightyP, 5, 250, 289, 39);
assert_ref_delta(CommonResolution::TenEightyP, 10, 500, 578, 78);
assert_ref_delta(CommonResolution::TenEightyP, 15, 750, 867, 117);
}
#[test]
fn refs_cost_more_at_4k() {
assert_ref_delta(CommonResolution::FourK, 5, 433, 569, 136);
assert_ref_delta(CommonResolution::FourK, 10, 866, 1138, 272);
assert_ref_delta(CommonResolution::FourK, 15, 1299, 1707, 408);
}
/// Price the same generation with and without a reference video; pin
/// both prices and the delta, in USD cents AND credits (credits equal
/// cents, and both must show references costing more).
fn assert_ref_delta(
resolution: CommonResolution,
duration_seconds: u16,
expected_no_ref: u64,
expected_with_ref: u64,
expected_delta: u64,
) {
let no_ref = ArtcraftSeedance2p0BytePlusCostState {
resolution, duration_seconds, batch_count: 1, has_video_reference: false,
}.estimate_cost();
let with_ref = ArtcraftSeedance2p0BytePlusCostState {
resolution, duration_seconds, batch_count: 1, has_video_reference: true,
}.estimate_cost();
let no_ref_cents = no_ref.cost_in_usd_cents.unwrap();
let with_ref_cents = with_ref.cost_in_usd_cents.unwrap();
assert_eq!(no_ref_cents, expected_no_ref);
assert_eq!(with_ref_cents, expected_with_ref);
assert_eq!(with_ref_cents - no_ref_cents, expected_delta);
assert!(with_ref_cents > no_ref_cents, "references must cost more");
let no_ref_credits = no_ref.cost_in_credits.unwrap();
let with_ref_credits = with_ref.cost_in_credits.unwrap();
assert_eq!(no_ref_credits, expected_no_ref);
assert_eq!(with_ref_credits, expected_with_ref);
assert_eq!(with_ref_credits - no_ref_credits, expected_delta);
}
}
}
@@ -9,10 +9,20 @@ use crate::generate::generate_video::providers::artcraft::seedance_2p0_bp_fast::
const CENTS_PER_SECOND_480P: f64 = 9.0;
const CENTS_PER_SECOND_720P: f64 = 20.0;
/// USD cents per second, in hundredths of a cent, when one or more
/// reference videos are attached. Held as integer hundredths so the math is
/// exact; rounded up to whole cents once, after multiplying by
/// duration × batch.
/// 480p: 9.65 ¢/s
/// 720p: 20.50 ¢/s
const WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_480P: u64 = 965;
const WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_720P: u64 = 2_050;
pub struct ArtcraftSeedance2p0BytePlusFastCostState {
pub resolution: CommonResolution,
pub duration_seconds: u16,
pub batch_count: u16,
pub has_video_reference: bool,
}
impl ArtcraftSeedance2p0BytePlusFastCostState {
@@ -21,10 +31,26 @@ impl ArtcraftSeedance2p0BytePlusFastCostState {
.unwrap_or(CommonResolution::SevenTwentyP);
let duration_seconds = request.request.duration_seconds.unwrap_or(5);
let batch_count = request.request.video_batch_count.unwrap_or(1);
Self { resolution, duration_seconds, batch_count }
let has_video_reference = request.request.reference_video_media_tokens
.as_ref()
.is_some_and(|tokens| !tokens.is_empty());
Self { resolution, duration_seconds, batch_count, has_video_reference }
}
pub fn estimate_cost(&self) -> VideoGenerationCostEstimate {
if self.has_video_reference {
let usd_cents = self.with_video_reference_usd_cents();
return VideoGenerationCostEstimate {
cost_in_credits: Some(usd_cents),
cost_in_usd_cents: Some(usd_cents),
is_free: false,
is_unlimited: false,
is_rate_limited: false,
has_watermark: false,
failures_are_refunded: None,
};
}
let cents_per_second = match self.resolution {
CommonResolution::FourEightyP => CENTS_PER_SECOND_480P,
_ => CENTS_PER_SECOND_720P,
@@ -42,6 +68,20 @@ impl ArtcraftSeedance2p0BytePlusFastCostState {
failures_are_refunded: None,
}
}
/// Price when one or more reference videos are attached.
fn with_video_reference_usd_cents(&self) -> u64 {
let centi_cents_per_second = match self.resolution {
CommonResolution::FourEightyP => WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_480P,
// Everything else (including 720p) prices at 720p.
_ => WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_720P,
};
let seconds = self.duration_seconds as u64 * self.batch_count as u64;
// Round up to whole cents.
(centi_cents_per_second * seconds).div_ceil(100)
}
}
#[cfg(test)]
@@ -12,6 +12,19 @@ const CENTS_PER_SECOND_480P: f64 = 10.0;
const CENTS_PER_SECOND_720P: f64 = 25.0;
const CENTS_PER_SECOND_1080P: f64 = 50.0;
/// USD cents per second, in hundredths of a cent, when one or more
/// reference videos are attached. Held as integer hundredths so the math is
/// exact; rounded up to whole cents once, after multiplying by
/// duration × batch.
/// 480p: 10.20 ¢/s
/// 720p: 25.70 ¢/s
/// 1080p: 57.80 ¢/s
/// 4K: 113.80 ¢/s
const WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_480P: u64 = 1_020;
const WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_720P: u64 = 2_570;
const WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_1080P: u64 = 5_780;
const WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_4K: u64 = 11_380;
pub struct ArtcraftSeedance2p0BytePlusUltraCostState {
pub resolution: CommonResolution,
pub duration_seconds: u16,
@@ -32,11 +45,23 @@ impl ArtcraftSeedance2p0BytePlusUltraCostState {
}
pub fn estimate_cost(&self) -> VideoGenerationCostEstimate {
if self.has_video_reference {
let usd_cents = self.with_video_reference_usd_cents();
return VideoGenerationCostEstimate {
cost_in_credits: Some(usd_cents),
cost_in_usd_cents: Some(usd_cents),
is_free: false,
is_unlimited: false,
is_rate_limited: false,
has_watermark: false,
failures_are_refunded: None,
};
}
if self.resolution == CommonResolution::FourK {
let usd_cents = seedance_2p0_four_k_usd_cents(
self.duration_seconds,
self.batch_count,
self.has_video_reference,
);
return VideoGenerationCostEstimate {
cost_in_credits: Some(usd_cents),
@@ -67,6 +92,22 @@ impl ArtcraftSeedance2p0BytePlusUltraCostState {
failures_are_refunded: None,
}
}
/// Price when one or more reference videos are attached.
fn with_video_reference_usd_cents(&self) -> u64 {
let centi_cents_per_second = match self.resolution {
CommonResolution::FourEightyP => WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_480P,
CommonResolution::TenEightyP => WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_1080P,
CommonResolution::FourK => WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_4K,
// Everything else (including 720p) prices at 720p.
_ => WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_720P,
};
let seconds = self.duration_seconds as u64 * self.batch_count as u64;
// Round up to whole cents.
(centi_cents_per_second * seconds).div_ceil(100)
}
}
#[cfg(test)]
@@ -187,10 +228,11 @@ mod tests {
#[test]
fn explicit_4k_with_video_reference() {
assert_eq!(artcraft_4k_cents(4, 1, true), 416);
assert_eq!(artcraft_4k_cents(5, 1, true), 519);
assert_eq!(artcraft_4k_cents(10, 1, true), 1038);
assert_eq!(artcraft_4k_cents(15, 1, true), 1557);
// 113.80 ¢/s with-reference card, rounded up to whole cents.
assert_eq!(artcraft_4k_cents(4, 1, true), 456);
assert_eq!(artcraft_4k_cents(5, 1, true), 569);
assert_eq!(artcraft_4k_cents(10, 1, true), 1138);
assert_eq!(artcraft_4k_cents(15, 1, true), 1707);
}
}
@@ -243,4 +285,74 @@ mod tests {
fn cost_cents(resolution: Option<RouterResolution>, duration_seconds: u16, video_batch_count: u16) -> u64 {
build_cost(resolution, duration_seconds, video_batch_count).cost_in_usd_cents.unwrap()
}
// ── Video reference deltas ──
//
// References price on the with-reference rate card (10.20/25.70/57.80/113.80 ¢/s); the delta must be positive at every resolution and duration.
mod video_reference_deltas {
use enums::common::generation::common_resolution::CommonResolution;
use super::super::ArtcraftSeedance2p0BytePlusUltraCostState;
#[test]
fn refs_cost_more_at_480p() {
assert_ref_delta(CommonResolution::FourEightyP, 5, 50, 51, 1);
assert_ref_delta(CommonResolution::FourEightyP, 10, 100, 102, 2);
assert_ref_delta(CommonResolution::FourEightyP, 15, 150, 153, 3);
}
#[test]
fn refs_cost_more_at_720p() {
assert_ref_delta(CommonResolution::SevenTwentyP, 5, 125, 129, 4);
assert_ref_delta(CommonResolution::SevenTwentyP, 10, 250, 257, 7);
assert_ref_delta(CommonResolution::SevenTwentyP, 15, 375, 386, 11);
}
#[test]
fn refs_cost_more_at_1080p() {
assert_ref_delta(CommonResolution::TenEightyP, 5, 250, 289, 39);
assert_ref_delta(CommonResolution::TenEightyP, 10, 500, 578, 78);
assert_ref_delta(CommonResolution::TenEightyP, 15, 750, 867, 117);
}
#[test]
fn refs_cost_more_at_4k() {
assert_ref_delta(CommonResolution::FourK, 5, 433, 569, 136);
assert_ref_delta(CommonResolution::FourK, 10, 866, 1138, 272);
assert_ref_delta(CommonResolution::FourK, 15, 1299, 1707, 408);
}
/// Price the same generation with and without a reference video; pin
/// both prices and the delta, in USD cents AND credits (credits equal
/// cents, and both must show references costing more).
fn assert_ref_delta(
resolution: CommonResolution,
duration_seconds: u16,
expected_no_ref: u64,
expected_with_ref: u64,
expected_delta: u64,
) {
let no_ref = ArtcraftSeedance2p0BytePlusUltraCostState {
resolution, duration_seconds, batch_count: 1, has_video_reference: false,
}.estimate_cost();
let with_ref = ArtcraftSeedance2p0BytePlusUltraCostState {
resolution, duration_seconds, batch_count: 1, has_video_reference: true,
}.estimate_cost();
let no_ref_cents = no_ref.cost_in_usd_cents.unwrap();
let with_ref_cents = with_ref.cost_in_usd_cents.unwrap();
assert_eq!(no_ref_cents, expected_no_ref);
assert_eq!(with_ref_cents, expected_with_ref);
assert_eq!(with_ref_cents - no_ref_cents, expected_delta);
assert!(with_ref_cents > no_ref_cents, "references must cost more");
let no_ref_credits = no_ref.cost_in_credits.unwrap();
let with_ref_credits = with_ref.cost_in_credits.unwrap();
assert_eq!(no_ref_credits, expected_no_ref);
assert_eq!(with_ref_credits, expected_with_ref);
assert_eq!(with_ref_credits - no_ref_credits, expected_delta);
}
}
}
@@ -9,10 +9,20 @@ use crate::generate::generate_video::providers::artcraft::seedance_2p0_bpu_fast:
const CENTS_PER_SECOND_480P: f64 = 9.0;
const CENTS_PER_SECOND_720P: f64 = 20.0;
/// USD cents per second, in hundredths of a cent, when one or more
/// reference videos are attached. Held as integer hundredths so the math is
/// exact; rounded up to whole cents once, after multiplying by
/// duration × batch.
/// 480p: 9.65 ¢/s
/// 720p: 20.50 ¢/s
const WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_480P: u64 = 965;
const WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_720P: u64 = 2_050;
pub struct ArtcraftSeedance2p0BytePlusUltraFastCostState {
pub resolution: CommonResolution,
pub duration_seconds: u16,
pub batch_count: u16,
pub has_video_reference: bool,
}
impl ArtcraftSeedance2p0BytePlusUltraFastCostState {
@@ -21,10 +31,26 @@ impl ArtcraftSeedance2p0BytePlusUltraFastCostState {
.unwrap_or(CommonResolution::SevenTwentyP);
let duration_seconds = request.request.duration_seconds.unwrap_or(5);
let batch_count = request.request.video_batch_count.unwrap_or(1);
Self { resolution, duration_seconds, batch_count }
let has_video_reference = request.request.reference_video_media_tokens
.as_ref()
.is_some_and(|tokens| !tokens.is_empty());
Self { resolution, duration_seconds, batch_count, has_video_reference }
}
pub fn estimate_cost(&self) -> VideoGenerationCostEstimate {
if self.has_video_reference {
let usd_cents = self.with_video_reference_usd_cents();
return VideoGenerationCostEstimate {
cost_in_credits: Some(usd_cents),
cost_in_usd_cents: Some(usd_cents),
is_free: false,
is_unlimited: false,
is_rate_limited: false,
has_watermark: false,
failures_are_refunded: None,
};
}
let cents_per_second = match self.resolution {
CommonResolution::FourEightyP => CENTS_PER_SECOND_480P,
_ => CENTS_PER_SECOND_720P,
@@ -42,6 +68,20 @@ impl ArtcraftSeedance2p0BytePlusUltraFastCostState {
failures_are_refunded: None,
}
}
/// Price when one or more reference videos are attached.
fn with_video_reference_usd_cents(&self) -> u64 {
let centi_cents_per_second = match self.resolution {
CommonResolution::FourEightyP => WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_480P,
// Everything else (including 720p) prices at 720p.
_ => WITH_VIDEO_REFERENCE_CENTI_CENTS_PER_SECOND_720P,
};
let seconds = self.duration_seconds as u64 * self.batch_count as u64;
// Round up to whole cents.
(centi_cents_per_second * seconds).div_ceil(100)
}
}
#[cfg(test)]
@@ -14,27 +14,16 @@ use kinovi_web_client::generate::video::generate_seedance_2p5::{
/// 4K output price, in hundredths of a USD cent per second (86.60 ¢/s).
const FOUR_K_CENTI_CENTS_PER_SECOND: u64 = 8660;
/// Extra hundredths of a USD cent per second when a reference video is attached
/// at 4K (17.20 ¢/s surcharge).
const FOUR_K_VIDEO_REFERENCE_SURCHARGE_CENTI_CENTS_PER_SECOND: u64 = 1720;
/// ArtCraft's price (USD cents) for Seedance 2.0 at 4K.
///
/// A reference video adds a per-second surcharge (4K with and without a video
/// reference are priced differently). The cost scales with duration and batch
/// count, rounded up to whole cents.
/// ArtCraft's price (USD cents) for Seedance 2.0 at 4K with no reference
/// videos attached. Each model prices reference videos through its own
/// with-reference rate card. The cost scales with duration and batch count,
/// rounded up to whole cents.
pub fn seedance_2p0_four_k_usd_cents(
duration_seconds: u16,
batch_count: u16,
has_video_reference: bool,
) -> u64 {
let mut centi_cents_per_second = FOUR_K_CENTI_CENTS_PER_SECOND;
if has_video_reference {
centi_cents_per_second += FOUR_K_VIDEO_REFERENCE_SURCHARGE_CENTI_CENTS_PER_SECOND;
}
let total_centi_cents =
centi_cents_per_second * duration_seconds as u64 * batch_count as u64;
FOUR_K_CENTI_CENTS_PER_SECOND * duration_seconds as u64 * batch_count as u64;
// Round up to whole cents.
total_centi_cents.div_ceil(100)
@@ -263,37 +252,17 @@ mod tests {
use super::*;
#[test]
fn four_k_without_video_reference() {
assert_eq!(seedance_2p0_four_k_usd_cents(4, 1, false), 347);
assert_eq!(seedance_2p0_four_k_usd_cents(5, 1, false), 433);
assert_eq!(seedance_2p0_four_k_usd_cents(10, 1, false), 866);
assert_eq!(seedance_2p0_four_k_usd_cents(15, 1, false), 1299);
}
#[test]
fn four_k_with_video_reference() {
assert_eq!(seedance_2p0_four_k_usd_cents(4, 1, true), 416);
assert_eq!(seedance_2p0_four_k_usd_cents(5, 1, true), 519);
assert_eq!(seedance_2p0_four_k_usd_cents(10, 1, true), 1038);
assert_eq!(seedance_2p0_four_k_usd_cents(15, 1, true), 1557);
}
#[test]
fn video_reference_always_costs_more() {
for &duration in &[4u16, 5, 10, 15] {
assert!(
seedance_2p0_four_k_usd_cents(duration, 1, true)
> seedance_2p0_four_k_usd_cents(duration, 1, false),
"video reference should cost more at {duration}s",
);
}
fn four_k_base_prices() {
assert_eq!(seedance_2p0_four_k_usd_cents(4, 1), 347);
assert_eq!(seedance_2p0_four_k_usd_cents(5, 1), 433);
assert_eq!(seedance_2p0_four_k_usd_cents(10, 1), 866);
assert_eq!(seedance_2p0_four_k_usd_cents(15, 1), 1299);
}
#[test]
fn batch_count_multiplies() {
assert_eq!(seedance_2p0_four_k_usd_cents(5, 2, false), 866);
assert_eq!(seedance_2p0_four_k_usd_cents(5, 4, false), 1732);
assert_eq!(seedance_2p0_four_k_usd_cents(5, 2, true), 1038);
assert_eq!(seedance_2p0_four_k_usd_cents(5, 2), 866);
assert_eq!(seedance_2p0_four_k_usd_cents(5, 4), 1732);
}
// ── Seedance 2.0 Mini ──
@@ -12,7 +12,7 @@ use enums::common::generation::common_resolution::CommonResolution;
use enums::common::generation::common_video_model::CommonVideoModel;
use crate::http_server::endpoints::omni_gen::generate::video::tests::support::{
assert_generation_fails_and_charges_nothing, assert_reference_video_charge_then_refund,
assert_generation_fails_and_charges_nothing, assert_reference_video_charge_then_refund, assert_references_charge_more,
assert_successful_generation_charges, assert_variant_charges_premium, Batch, CreditsDelta,
ExpectedCredits, Seconds, TestHarness,
};
@@ -311,6 +311,22 @@ mod seedance_2p0_fast {
/// With video references Fast switches to its with-references rate card (480p 8.41, 720p 15.60 cents/s, ceil-rounded). Charges are asserted on the refunded ledger entry (the fixture media is unreachable).
/// Spot checks across duration x batch x resolution.
/// References must be CHARGED more than the identical no-reference
/// request, at every resolution and across durations.
#[tokio::test]
#[cfg_attr(feature = "skip_database_tests", ignore)]
async fn video_references_charge_more_than_no_references() {
let harness = TestHarness::create().await;
for resolution in [CommonResolution::FourEightyP, CommonResolution::SevenTwentyP] {
for seconds in [5u16, 10, 15] {
assert_references_charge_more(
&harness, CommonVideoModel::Seedance2p0Fast, Some(resolution), Seconds(seconds),
).await;
}
}
}
#[tokio::test]
#[cfg_attr(feature = "skip_database_tests", ignore)]
async fn video_references_charge_spot_checked_combinations() {
@@ -528,54 +544,54 @@ mod seedance_2p0_bp_fast {
let harness = TestHarness::create().await;
let cases: &[(Option<CommonResolution>, Seconds, Batch, ExpectedCredits)] = &[
(Some(CommonResolution::FourEightyP), Seconds(4), Batch(1), ExpectedCredits(36)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(1), ExpectedCredits(45)),
(Some(CommonResolution::FourEightyP), Seconds(6), Batch(1), ExpectedCredits(54)),
(Some(CommonResolution::FourEightyP), Seconds(7), Batch(1), ExpectedCredits(63)),
(Some(CommonResolution::FourEightyP), Seconds(8), Batch(1), ExpectedCredits(72)),
(Some(CommonResolution::FourEightyP), Seconds(9), Batch(1), ExpectedCredits(81)),
(Some(CommonResolution::FourEightyP), Seconds(10), Batch(1), ExpectedCredits(90)),
(Some(CommonResolution::FourEightyP), Seconds(11), Batch(1), ExpectedCredits(99)),
(Some(CommonResolution::FourEightyP), Seconds(12), Batch(1), ExpectedCredits(108)),
(Some(CommonResolution::FourEightyP), Seconds(13), Batch(1), ExpectedCredits(117)),
(Some(CommonResolution::FourEightyP), Seconds(14), Batch(1), ExpectedCredits(126)),
(Some(CommonResolution::FourEightyP), Seconds(15), Batch(1), ExpectedCredits(135)),
(Some(CommonResolution::SevenTwentyP), Seconds(4), Batch(1), ExpectedCredits(80)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(1), ExpectedCredits(100)),
(Some(CommonResolution::SevenTwentyP), Seconds(6), Batch(1), ExpectedCredits(120)),
(Some(CommonResolution::SevenTwentyP), Seconds(7), Batch(1), ExpectedCredits(140)),
(Some(CommonResolution::SevenTwentyP), Seconds(8), Batch(1), ExpectedCredits(160)),
(Some(CommonResolution::SevenTwentyP), Seconds(9), Batch(1), ExpectedCredits(180)),
(Some(CommonResolution::SevenTwentyP), Seconds(10), Batch(1), ExpectedCredits(200)),
(Some(CommonResolution::SevenTwentyP), Seconds(11), Batch(1), ExpectedCredits(220)),
(Some(CommonResolution::SevenTwentyP), Seconds(12), Batch(1), ExpectedCredits(240)),
(Some(CommonResolution::SevenTwentyP), Seconds(13), Batch(1), ExpectedCredits(260)),
(Some(CommonResolution::SevenTwentyP), Seconds(14), Batch(1), ExpectedCredits(280)),
(Some(CommonResolution::SevenTwentyP), Seconds(15), Batch(1), ExpectedCredits(300)),
(Some(CommonResolution::TenEightyP), Seconds(4), Batch(1), ExpectedCredits(80)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(1), ExpectedCredits(100)),
(Some(CommonResolution::TenEightyP), Seconds(6), Batch(1), ExpectedCredits(120)),
(Some(CommonResolution::TenEightyP), Seconds(7), Batch(1), ExpectedCredits(140)),
(Some(CommonResolution::TenEightyP), Seconds(8), Batch(1), ExpectedCredits(160)),
(Some(CommonResolution::TenEightyP), Seconds(9), Batch(1), ExpectedCredits(180)),
(Some(CommonResolution::TenEightyP), Seconds(10), Batch(1), ExpectedCredits(200)),
(Some(CommonResolution::TenEightyP), Seconds(11), Batch(1), ExpectedCredits(220)),
(Some(CommonResolution::TenEightyP), Seconds(12), Batch(1), ExpectedCredits(240)),
(Some(CommonResolution::TenEightyP), Seconds(13), Batch(1), ExpectedCredits(260)),
(Some(CommonResolution::TenEightyP), Seconds(14), Batch(1), ExpectedCredits(280)),
(Some(CommonResolution::TenEightyP), Seconds(15), Batch(1), ExpectedCredits(300)),
(Some(CommonResolution::FourK), Seconds(4), Batch(1), ExpectedCredits(80)),
(Some(CommonResolution::FourK), Seconds(5), Batch(1), ExpectedCredits(100)),
(Some(CommonResolution::FourK), Seconds(6), Batch(1), ExpectedCredits(120)),
(Some(CommonResolution::FourK), Seconds(7), Batch(1), ExpectedCredits(140)),
(Some(CommonResolution::FourK), Seconds(8), Batch(1), ExpectedCredits(160)),
(Some(CommonResolution::FourK), Seconds(9), Batch(1), ExpectedCredits(180)),
(Some(CommonResolution::FourK), Seconds(10), Batch(1), ExpectedCredits(200)),
(Some(CommonResolution::FourK), Seconds(11), Batch(1), ExpectedCredits(220)),
(Some(CommonResolution::FourK), Seconds(12), Batch(1), ExpectedCredits(240)),
(Some(CommonResolution::FourK), Seconds(13), Batch(1), ExpectedCredits(260)),
(Some(CommonResolution::FourK), Seconds(14), Batch(1), ExpectedCredits(280)),
(Some(CommonResolution::FourK), Seconds(15), Batch(1), ExpectedCredits(300)),
(Some(CommonResolution::FourEightyP), Seconds(4), Batch(1), ExpectedCredits(39)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(1), ExpectedCredits(49)),
(Some(CommonResolution::FourEightyP), Seconds(6), Batch(1), ExpectedCredits(58)),
(Some(CommonResolution::FourEightyP), Seconds(7), Batch(1), ExpectedCredits(68)),
(Some(CommonResolution::FourEightyP), Seconds(8), Batch(1), ExpectedCredits(78)),
(Some(CommonResolution::FourEightyP), Seconds(9), Batch(1), ExpectedCredits(87)),
(Some(CommonResolution::FourEightyP), Seconds(10), Batch(1), ExpectedCredits(97)),
(Some(CommonResolution::FourEightyP), Seconds(11), Batch(1), ExpectedCredits(107)),
(Some(CommonResolution::FourEightyP), Seconds(12), Batch(1), ExpectedCredits(116)),
(Some(CommonResolution::FourEightyP), Seconds(13), Batch(1), ExpectedCredits(126)),
(Some(CommonResolution::FourEightyP), Seconds(14), Batch(1), ExpectedCredits(136)),
(Some(CommonResolution::FourEightyP), Seconds(15), Batch(1), ExpectedCredits(145)),
(Some(CommonResolution::SevenTwentyP), Seconds(4), Batch(1), ExpectedCredits(82)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(1), ExpectedCredits(103)),
(Some(CommonResolution::SevenTwentyP), Seconds(6), Batch(1), ExpectedCredits(123)),
(Some(CommonResolution::SevenTwentyP), Seconds(7), Batch(1), ExpectedCredits(144)),
(Some(CommonResolution::SevenTwentyP), Seconds(8), Batch(1), ExpectedCredits(164)),
(Some(CommonResolution::SevenTwentyP), Seconds(9), Batch(1), ExpectedCredits(185)),
(Some(CommonResolution::SevenTwentyP), Seconds(10), Batch(1), ExpectedCredits(205)),
(Some(CommonResolution::SevenTwentyP), Seconds(11), Batch(1), ExpectedCredits(226)),
(Some(CommonResolution::SevenTwentyP), Seconds(12), Batch(1), ExpectedCredits(246)),
(Some(CommonResolution::SevenTwentyP), Seconds(13), Batch(1), ExpectedCredits(267)),
(Some(CommonResolution::SevenTwentyP), Seconds(14), Batch(1), ExpectedCredits(287)),
(Some(CommonResolution::SevenTwentyP), Seconds(15), Batch(1), ExpectedCredits(308)),
(Some(CommonResolution::TenEightyP), Seconds(4), Batch(1), ExpectedCredits(82)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(1), ExpectedCredits(103)),
(Some(CommonResolution::TenEightyP), Seconds(6), Batch(1), ExpectedCredits(123)),
(Some(CommonResolution::TenEightyP), Seconds(7), Batch(1), ExpectedCredits(144)),
(Some(CommonResolution::TenEightyP), Seconds(8), Batch(1), ExpectedCredits(164)),
(Some(CommonResolution::TenEightyP), Seconds(9), Batch(1), ExpectedCredits(185)),
(Some(CommonResolution::TenEightyP), Seconds(10), Batch(1), ExpectedCredits(205)),
(Some(CommonResolution::TenEightyP), Seconds(11), Batch(1), ExpectedCredits(226)),
(Some(CommonResolution::TenEightyP), Seconds(12), Batch(1), ExpectedCredits(246)),
(Some(CommonResolution::TenEightyP), Seconds(13), Batch(1), ExpectedCredits(267)),
(Some(CommonResolution::TenEightyP), Seconds(14), Batch(1), ExpectedCredits(287)),
(Some(CommonResolution::TenEightyP), Seconds(15), Batch(1), ExpectedCredits(308)),
(Some(CommonResolution::FourK), Seconds(4), Batch(1), ExpectedCredits(82)),
(Some(CommonResolution::FourK), Seconds(5), Batch(1), ExpectedCredits(103)),
(Some(CommonResolution::FourK), Seconds(6), Batch(1), ExpectedCredits(123)),
(Some(CommonResolution::FourK), Seconds(7), Batch(1), ExpectedCredits(144)),
(Some(CommonResolution::FourK), Seconds(8), Batch(1), ExpectedCredits(164)),
(Some(CommonResolution::FourK), Seconds(9), Batch(1), ExpectedCredits(185)),
(Some(CommonResolution::FourK), Seconds(10), Batch(1), ExpectedCredits(205)),
(Some(CommonResolution::FourK), Seconds(11), Batch(1), ExpectedCredits(226)),
(Some(CommonResolution::FourK), Seconds(12), Batch(1), ExpectedCredits(246)),
(Some(CommonResolution::FourK), Seconds(13), Batch(1), ExpectedCredits(267)),
(Some(CommonResolution::FourK), Seconds(14), Batch(1), ExpectedCredits(287)),
(Some(CommonResolution::FourK), Seconds(15), Batch(1), ExpectedCredits(308)),
];
for (resolution, seconds, batch, expected) in cases {
@@ -594,46 +610,46 @@ mod seedance_2p0_bp_fast {
let harness = TestHarness::create().await;
let cases: &[(Option<CommonResolution>, Seconds, Batch, ExpectedCredits)] = &[
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(1), ExpectedCredits(45)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(2), ExpectedCredits(90)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(3), ExpectedCredits(135)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(4), ExpectedCredits(180)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(5), ExpectedCredits(180)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(6), ExpectedCredits(180)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(7), ExpectedCredits(180)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(8), ExpectedCredits(180)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(9), ExpectedCredits(180)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(10), ExpectedCredits(180)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(1), ExpectedCredits(100)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(2), ExpectedCredits(200)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(3), ExpectedCredits(300)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(4), ExpectedCredits(400)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(5), ExpectedCredits(400)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(6), ExpectedCredits(400)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(7), ExpectedCredits(400)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(8), ExpectedCredits(400)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(9), ExpectedCredits(400)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(10), ExpectedCredits(400)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(1), ExpectedCredits(100)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(2), ExpectedCredits(200)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(3), ExpectedCredits(300)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(4), ExpectedCredits(400)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(5), ExpectedCredits(400)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(6), ExpectedCredits(400)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(7), ExpectedCredits(400)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(8), ExpectedCredits(400)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(9), ExpectedCredits(400)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(10), ExpectedCredits(400)),
(Some(CommonResolution::FourK), Seconds(5), Batch(1), ExpectedCredits(100)),
(Some(CommonResolution::FourK), Seconds(5), Batch(2), ExpectedCredits(200)),
(Some(CommonResolution::FourK), Seconds(5), Batch(3), ExpectedCredits(300)),
(Some(CommonResolution::FourK), Seconds(5), Batch(4), ExpectedCredits(400)),
(Some(CommonResolution::FourK), Seconds(5), Batch(5), ExpectedCredits(400)),
(Some(CommonResolution::FourK), Seconds(5), Batch(6), ExpectedCredits(400)),
(Some(CommonResolution::FourK), Seconds(5), Batch(7), ExpectedCredits(400)),
(Some(CommonResolution::FourK), Seconds(5), Batch(8), ExpectedCredits(400)),
(Some(CommonResolution::FourK), Seconds(5), Batch(9), ExpectedCredits(400)),
(Some(CommonResolution::FourK), Seconds(5), Batch(10), ExpectedCredits(400)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(1), ExpectedCredits(49)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(2), ExpectedCredits(97)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(3), ExpectedCredits(145)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(4), ExpectedCredits(193)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(5), ExpectedCredits(193)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(6), ExpectedCredits(193)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(7), ExpectedCredits(193)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(8), ExpectedCredits(193)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(9), ExpectedCredits(193)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(10), ExpectedCredits(193)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(1), ExpectedCredits(103)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(2), ExpectedCredits(205)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(3), ExpectedCredits(308)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(4), ExpectedCredits(410)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(5), ExpectedCredits(410)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(6), ExpectedCredits(410)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(7), ExpectedCredits(410)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(8), ExpectedCredits(410)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(9), ExpectedCredits(410)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(10), ExpectedCredits(410)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(1), ExpectedCredits(103)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(2), ExpectedCredits(205)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(3), ExpectedCredits(308)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(4), ExpectedCredits(410)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(5), ExpectedCredits(410)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(6), ExpectedCredits(410)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(7), ExpectedCredits(410)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(8), ExpectedCredits(410)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(9), ExpectedCredits(410)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(10), ExpectedCredits(410)),
(Some(CommonResolution::FourK), Seconds(5), Batch(1), ExpectedCredits(103)),
(Some(CommonResolution::FourK), Seconds(5), Batch(2), ExpectedCredits(205)),
(Some(CommonResolution::FourK), Seconds(5), Batch(3), ExpectedCredits(308)),
(Some(CommonResolution::FourK), Seconds(5), Batch(4), ExpectedCredits(410)),
(Some(CommonResolution::FourK), Seconds(5), Batch(5), ExpectedCredits(410)),
(Some(CommonResolution::FourK), Seconds(5), Batch(6), ExpectedCredits(410)),
(Some(CommonResolution::FourK), Seconds(5), Batch(7), ExpectedCredits(410)),
(Some(CommonResolution::FourK), Seconds(5), Batch(8), ExpectedCredits(410)),
(Some(CommonResolution::FourK), Seconds(5), Batch(9), ExpectedCredits(410)),
(Some(CommonResolution::FourK), Seconds(5), Batch(10), ExpectedCredits(410)),
];
for (resolution, seconds, batch, expected) in cases {
@@ -645,36 +661,52 @@ mod seedance_2p0_bp_fast {
/// The BytePlus Fast rate card is flat: reference videos never change the price. Charges are asserted on the refunded ledger entry (the fixture media is unreachable).
/// Spot checks across duration x batch x resolution.
/// References must be CHARGED more than the identical no-reference
/// request, at every resolution and across durations.
#[tokio::test]
#[cfg_attr(feature = "skip_database_tests", ignore)]
async fn video_references_charge_more_than_no_references() {
let harness = TestHarness::create().await;
for resolution in [CommonResolution::FourEightyP, CommonResolution::SevenTwentyP] {
for seconds in [5u16, 10, 15] {
assert_references_charge_more(
&harness, CommonVideoModel::Seedance2p0BytePlusFast, Some(resolution), Seconds(seconds),
).await;
}
}
}
#[tokio::test]
#[cfg_attr(feature = "skip_database_tests", ignore)]
async fn video_references_charge_spot_checked_combinations() {
let harness = TestHarness::create().await;
let cases: &[(Option<CommonResolution>, Seconds, Batch, ExpectedCredits)] = &[
(Some(CommonResolution::FourEightyP), Seconds(6), Batch(2), ExpectedCredits(108)),
(Some(CommonResolution::FourEightyP), Seconds(7), Batch(3), ExpectedCredits(189)),
(Some(CommonResolution::FourEightyP), Seconds(9), Batch(4), ExpectedCredits(324)),
(Some(CommonResolution::FourEightyP), Seconds(11), Batch(5), ExpectedCredits(396)),
(Some(CommonResolution::FourEightyP), Seconds(13), Batch(8), ExpectedCredits(468)),
(Some(CommonResolution::FourEightyP), Seconds(15), Batch(10), ExpectedCredits(540)),
(Some(CommonResolution::SevenTwentyP), Seconds(6), Batch(2), ExpectedCredits(240)),
(Some(CommonResolution::SevenTwentyP), Seconds(7), Batch(3), ExpectedCredits(420)),
(Some(CommonResolution::SevenTwentyP), Seconds(9), Batch(4), ExpectedCredits(720)),
(Some(CommonResolution::SevenTwentyP), Seconds(11), Batch(5), ExpectedCredits(880)),
(Some(CommonResolution::SevenTwentyP), Seconds(13), Batch(8), ExpectedCredits(1040)),
(Some(CommonResolution::SevenTwentyP), Seconds(15), Batch(10), ExpectedCredits(1200)),
(Some(CommonResolution::TenEightyP), Seconds(6), Batch(2), ExpectedCredits(240)),
(Some(CommonResolution::TenEightyP), Seconds(7), Batch(3), ExpectedCredits(420)),
(Some(CommonResolution::TenEightyP), Seconds(9), Batch(4), ExpectedCredits(720)),
(Some(CommonResolution::TenEightyP), Seconds(11), Batch(5), ExpectedCredits(880)),
(Some(CommonResolution::TenEightyP), Seconds(13), Batch(8), ExpectedCredits(1040)),
(Some(CommonResolution::TenEightyP), Seconds(15), Batch(10), ExpectedCredits(1200)),
(Some(CommonResolution::FourK), Seconds(6), Batch(2), ExpectedCredits(240)),
(Some(CommonResolution::FourK), Seconds(7), Batch(3), ExpectedCredits(420)),
(Some(CommonResolution::FourK), Seconds(9), Batch(4), ExpectedCredits(720)),
(Some(CommonResolution::FourK), Seconds(11), Batch(5), ExpectedCredits(880)),
(Some(CommonResolution::FourK), Seconds(13), Batch(8), ExpectedCredits(1040)),
(Some(CommonResolution::FourK), Seconds(15), Batch(10), ExpectedCredits(1200)),
(Some(CommonResolution::FourEightyP), Seconds(6), Batch(2), ExpectedCredits(116)),
(Some(CommonResolution::FourEightyP), Seconds(7), Batch(3), ExpectedCredits(203)),
(Some(CommonResolution::FourEightyP), Seconds(9), Batch(4), ExpectedCredits(348)),
(Some(CommonResolution::FourEightyP), Seconds(11), Batch(5), ExpectedCredits(425)),
(Some(CommonResolution::FourEightyP), Seconds(13), Batch(8), ExpectedCredits(502)),
(Some(CommonResolution::FourEightyP), Seconds(15), Batch(10), ExpectedCredits(579)),
(Some(CommonResolution::SevenTwentyP), Seconds(6), Batch(2), ExpectedCredits(246)),
(Some(CommonResolution::SevenTwentyP), Seconds(7), Batch(3), ExpectedCredits(431)),
(Some(CommonResolution::SevenTwentyP), Seconds(9), Batch(4), ExpectedCredits(738)),
(Some(CommonResolution::SevenTwentyP), Seconds(11), Batch(5), ExpectedCredits(902)),
(Some(CommonResolution::SevenTwentyP), Seconds(13), Batch(8), ExpectedCredits(1066)),
(Some(CommonResolution::SevenTwentyP), Seconds(15), Batch(10), ExpectedCredits(1230)),
(Some(CommonResolution::TenEightyP), Seconds(6), Batch(2), ExpectedCredits(246)),
(Some(CommonResolution::TenEightyP), Seconds(7), Batch(3), ExpectedCredits(431)),
(Some(CommonResolution::TenEightyP), Seconds(9), Batch(4), ExpectedCredits(738)),
(Some(CommonResolution::TenEightyP), Seconds(11), Batch(5), ExpectedCredits(902)),
(Some(CommonResolution::TenEightyP), Seconds(13), Batch(8), ExpectedCredits(1066)),
(Some(CommonResolution::TenEightyP), Seconds(15), Batch(10), ExpectedCredits(1230)),
(Some(CommonResolution::FourK), Seconds(6), Batch(2), ExpectedCredits(246)),
(Some(CommonResolution::FourK), Seconds(7), Batch(3), ExpectedCredits(431)),
(Some(CommonResolution::FourK), Seconds(9), Batch(4), ExpectedCredits(738)),
(Some(CommonResolution::FourK), Seconds(11), Batch(5), ExpectedCredits(902)),
(Some(CommonResolution::FourK), Seconds(13), Batch(8), ExpectedCredits(1066)),
(Some(CommonResolution::FourK), Seconds(15), Batch(10), ExpectedCredits(1230)),
];
for (resolution, seconds, batch, expected) in cases {
@@ -878,54 +910,54 @@ mod seedance_2p0_bpu_fast {
let harness = TestHarness::create().await;
let cases: &[(Option<CommonResolution>, Seconds, Batch, ExpectedCredits)] = &[
(Some(CommonResolution::FourEightyP), Seconds(4), Batch(1), ExpectedCredits(36)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(1), ExpectedCredits(45)),
(Some(CommonResolution::FourEightyP), Seconds(6), Batch(1), ExpectedCredits(54)),
(Some(CommonResolution::FourEightyP), Seconds(7), Batch(1), ExpectedCredits(63)),
(Some(CommonResolution::FourEightyP), Seconds(8), Batch(1), ExpectedCredits(72)),
(Some(CommonResolution::FourEightyP), Seconds(9), Batch(1), ExpectedCredits(81)),
(Some(CommonResolution::FourEightyP), Seconds(10), Batch(1), ExpectedCredits(90)),
(Some(CommonResolution::FourEightyP), Seconds(11), Batch(1), ExpectedCredits(99)),
(Some(CommonResolution::FourEightyP), Seconds(12), Batch(1), ExpectedCredits(108)),
(Some(CommonResolution::FourEightyP), Seconds(13), Batch(1), ExpectedCredits(117)),
(Some(CommonResolution::FourEightyP), Seconds(14), Batch(1), ExpectedCredits(126)),
(Some(CommonResolution::FourEightyP), Seconds(15), Batch(1), ExpectedCredits(135)),
(Some(CommonResolution::SevenTwentyP), Seconds(4), Batch(1), ExpectedCredits(80)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(1), ExpectedCredits(100)),
(Some(CommonResolution::SevenTwentyP), Seconds(6), Batch(1), ExpectedCredits(120)),
(Some(CommonResolution::SevenTwentyP), Seconds(7), Batch(1), ExpectedCredits(140)),
(Some(CommonResolution::SevenTwentyP), Seconds(8), Batch(1), ExpectedCredits(160)),
(Some(CommonResolution::SevenTwentyP), Seconds(9), Batch(1), ExpectedCredits(180)),
(Some(CommonResolution::SevenTwentyP), Seconds(10), Batch(1), ExpectedCredits(200)),
(Some(CommonResolution::SevenTwentyP), Seconds(11), Batch(1), ExpectedCredits(220)),
(Some(CommonResolution::SevenTwentyP), Seconds(12), Batch(1), ExpectedCredits(240)),
(Some(CommonResolution::SevenTwentyP), Seconds(13), Batch(1), ExpectedCredits(260)),
(Some(CommonResolution::SevenTwentyP), Seconds(14), Batch(1), ExpectedCredits(280)),
(Some(CommonResolution::SevenTwentyP), Seconds(15), Batch(1), ExpectedCredits(300)),
(Some(CommonResolution::TenEightyP), Seconds(4), Batch(1), ExpectedCredits(80)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(1), ExpectedCredits(100)),
(Some(CommonResolution::TenEightyP), Seconds(6), Batch(1), ExpectedCredits(120)),
(Some(CommonResolution::TenEightyP), Seconds(7), Batch(1), ExpectedCredits(140)),
(Some(CommonResolution::TenEightyP), Seconds(8), Batch(1), ExpectedCredits(160)),
(Some(CommonResolution::TenEightyP), Seconds(9), Batch(1), ExpectedCredits(180)),
(Some(CommonResolution::TenEightyP), Seconds(10), Batch(1), ExpectedCredits(200)),
(Some(CommonResolution::TenEightyP), Seconds(11), Batch(1), ExpectedCredits(220)),
(Some(CommonResolution::TenEightyP), Seconds(12), Batch(1), ExpectedCredits(240)),
(Some(CommonResolution::TenEightyP), Seconds(13), Batch(1), ExpectedCredits(260)),
(Some(CommonResolution::TenEightyP), Seconds(14), Batch(1), ExpectedCredits(280)),
(Some(CommonResolution::TenEightyP), Seconds(15), Batch(1), ExpectedCredits(300)),
(Some(CommonResolution::FourK), Seconds(4), Batch(1), ExpectedCredits(80)),
(Some(CommonResolution::FourK), Seconds(5), Batch(1), ExpectedCredits(100)),
(Some(CommonResolution::FourK), Seconds(6), Batch(1), ExpectedCredits(120)),
(Some(CommonResolution::FourK), Seconds(7), Batch(1), ExpectedCredits(140)),
(Some(CommonResolution::FourK), Seconds(8), Batch(1), ExpectedCredits(160)),
(Some(CommonResolution::FourK), Seconds(9), Batch(1), ExpectedCredits(180)),
(Some(CommonResolution::FourK), Seconds(10), Batch(1), ExpectedCredits(200)),
(Some(CommonResolution::FourK), Seconds(11), Batch(1), ExpectedCredits(220)),
(Some(CommonResolution::FourK), Seconds(12), Batch(1), ExpectedCredits(240)),
(Some(CommonResolution::FourK), Seconds(13), Batch(1), ExpectedCredits(260)),
(Some(CommonResolution::FourK), Seconds(14), Batch(1), ExpectedCredits(280)),
(Some(CommonResolution::FourK), Seconds(15), Batch(1), ExpectedCredits(300)),
(Some(CommonResolution::FourEightyP), Seconds(4), Batch(1), ExpectedCredits(39)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(1), ExpectedCredits(49)),
(Some(CommonResolution::FourEightyP), Seconds(6), Batch(1), ExpectedCredits(58)),
(Some(CommonResolution::FourEightyP), Seconds(7), Batch(1), ExpectedCredits(68)),
(Some(CommonResolution::FourEightyP), Seconds(8), Batch(1), ExpectedCredits(78)),
(Some(CommonResolution::FourEightyP), Seconds(9), Batch(1), ExpectedCredits(87)),
(Some(CommonResolution::FourEightyP), Seconds(10), Batch(1), ExpectedCredits(97)),
(Some(CommonResolution::FourEightyP), Seconds(11), Batch(1), ExpectedCredits(107)),
(Some(CommonResolution::FourEightyP), Seconds(12), Batch(1), ExpectedCredits(116)),
(Some(CommonResolution::FourEightyP), Seconds(13), Batch(1), ExpectedCredits(126)),
(Some(CommonResolution::FourEightyP), Seconds(14), Batch(1), ExpectedCredits(136)),
(Some(CommonResolution::FourEightyP), Seconds(15), Batch(1), ExpectedCredits(145)),
(Some(CommonResolution::SevenTwentyP), Seconds(4), Batch(1), ExpectedCredits(82)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(1), ExpectedCredits(103)),
(Some(CommonResolution::SevenTwentyP), Seconds(6), Batch(1), ExpectedCredits(123)),
(Some(CommonResolution::SevenTwentyP), Seconds(7), Batch(1), ExpectedCredits(144)),
(Some(CommonResolution::SevenTwentyP), Seconds(8), Batch(1), ExpectedCredits(164)),
(Some(CommonResolution::SevenTwentyP), Seconds(9), Batch(1), ExpectedCredits(185)),
(Some(CommonResolution::SevenTwentyP), Seconds(10), Batch(1), ExpectedCredits(205)),
(Some(CommonResolution::SevenTwentyP), Seconds(11), Batch(1), ExpectedCredits(226)),
(Some(CommonResolution::SevenTwentyP), Seconds(12), Batch(1), ExpectedCredits(246)),
(Some(CommonResolution::SevenTwentyP), Seconds(13), Batch(1), ExpectedCredits(267)),
(Some(CommonResolution::SevenTwentyP), Seconds(14), Batch(1), ExpectedCredits(287)),
(Some(CommonResolution::SevenTwentyP), Seconds(15), Batch(1), ExpectedCredits(308)),
(Some(CommonResolution::TenEightyP), Seconds(4), Batch(1), ExpectedCredits(82)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(1), ExpectedCredits(103)),
(Some(CommonResolution::TenEightyP), Seconds(6), Batch(1), ExpectedCredits(123)),
(Some(CommonResolution::TenEightyP), Seconds(7), Batch(1), ExpectedCredits(144)),
(Some(CommonResolution::TenEightyP), Seconds(8), Batch(1), ExpectedCredits(164)),
(Some(CommonResolution::TenEightyP), Seconds(9), Batch(1), ExpectedCredits(185)),
(Some(CommonResolution::TenEightyP), Seconds(10), Batch(1), ExpectedCredits(205)),
(Some(CommonResolution::TenEightyP), Seconds(11), Batch(1), ExpectedCredits(226)),
(Some(CommonResolution::TenEightyP), Seconds(12), Batch(1), ExpectedCredits(246)),
(Some(CommonResolution::TenEightyP), Seconds(13), Batch(1), ExpectedCredits(267)),
(Some(CommonResolution::TenEightyP), Seconds(14), Batch(1), ExpectedCredits(287)),
(Some(CommonResolution::TenEightyP), Seconds(15), Batch(1), ExpectedCredits(308)),
(Some(CommonResolution::FourK), Seconds(4), Batch(1), ExpectedCredits(82)),
(Some(CommonResolution::FourK), Seconds(5), Batch(1), ExpectedCredits(103)),
(Some(CommonResolution::FourK), Seconds(6), Batch(1), ExpectedCredits(123)),
(Some(CommonResolution::FourK), Seconds(7), Batch(1), ExpectedCredits(144)),
(Some(CommonResolution::FourK), Seconds(8), Batch(1), ExpectedCredits(164)),
(Some(CommonResolution::FourK), Seconds(9), Batch(1), ExpectedCredits(185)),
(Some(CommonResolution::FourK), Seconds(10), Batch(1), ExpectedCredits(205)),
(Some(CommonResolution::FourK), Seconds(11), Batch(1), ExpectedCredits(226)),
(Some(CommonResolution::FourK), Seconds(12), Batch(1), ExpectedCredits(246)),
(Some(CommonResolution::FourK), Seconds(13), Batch(1), ExpectedCredits(267)),
(Some(CommonResolution::FourK), Seconds(14), Batch(1), ExpectedCredits(287)),
(Some(CommonResolution::FourK), Seconds(15), Batch(1), ExpectedCredits(308)),
];
for (resolution, seconds, batch, expected) in cases {
@@ -944,46 +976,46 @@ mod seedance_2p0_bpu_fast {
let harness = TestHarness::create().await;
let cases: &[(Option<CommonResolution>, Seconds, Batch, ExpectedCredits)] = &[
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(1), ExpectedCredits(45)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(2), ExpectedCredits(90)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(3), ExpectedCredits(135)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(4), ExpectedCredits(180)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(5), ExpectedCredits(180)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(6), ExpectedCredits(180)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(7), ExpectedCredits(180)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(8), ExpectedCredits(180)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(9), ExpectedCredits(180)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(10), ExpectedCredits(180)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(1), ExpectedCredits(100)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(2), ExpectedCredits(200)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(3), ExpectedCredits(300)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(4), ExpectedCredits(400)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(5), ExpectedCredits(400)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(6), ExpectedCredits(400)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(7), ExpectedCredits(400)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(8), ExpectedCredits(400)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(9), ExpectedCredits(400)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(10), ExpectedCredits(400)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(1), ExpectedCredits(100)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(2), ExpectedCredits(200)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(3), ExpectedCredits(300)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(4), ExpectedCredits(400)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(5), ExpectedCredits(400)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(6), ExpectedCredits(400)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(7), ExpectedCredits(400)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(8), ExpectedCredits(400)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(9), ExpectedCredits(400)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(10), ExpectedCredits(400)),
(Some(CommonResolution::FourK), Seconds(5), Batch(1), ExpectedCredits(100)),
(Some(CommonResolution::FourK), Seconds(5), Batch(2), ExpectedCredits(200)),
(Some(CommonResolution::FourK), Seconds(5), Batch(3), ExpectedCredits(300)),
(Some(CommonResolution::FourK), Seconds(5), Batch(4), ExpectedCredits(400)),
(Some(CommonResolution::FourK), Seconds(5), Batch(5), ExpectedCredits(400)),
(Some(CommonResolution::FourK), Seconds(5), Batch(6), ExpectedCredits(400)),
(Some(CommonResolution::FourK), Seconds(5), Batch(7), ExpectedCredits(400)),
(Some(CommonResolution::FourK), Seconds(5), Batch(8), ExpectedCredits(400)),
(Some(CommonResolution::FourK), Seconds(5), Batch(9), ExpectedCredits(400)),
(Some(CommonResolution::FourK), Seconds(5), Batch(10), ExpectedCredits(400)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(1), ExpectedCredits(49)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(2), ExpectedCredits(97)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(3), ExpectedCredits(145)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(4), ExpectedCredits(193)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(5), ExpectedCredits(193)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(6), ExpectedCredits(193)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(7), ExpectedCredits(193)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(8), ExpectedCredits(193)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(9), ExpectedCredits(193)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(10), ExpectedCredits(193)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(1), ExpectedCredits(103)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(2), ExpectedCredits(205)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(3), ExpectedCredits(308)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(4), ExpectedCredits(410)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(5), ExpectedCredits(410)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(6), ExpectedCredits(410)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(7), ExpectedCredits(410)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(8), ExpectedCredits(410)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(9), ExpectedCredits(410)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(10), ExpectedCredits(410)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(1), ExpectedCredits(103)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(2), ExpectedCredits(205)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(3), ExpectedCredits(308)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(4), ExpectedCredits(410)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(5), ExpectedCredits(410)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(6), ExpectedCredits(410)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(7), ExpectedCredits(410)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(8), ExpectedCredits(410)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(9), ExpectedCredits(410)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(10), ExpectedCredits(410)),
(Some(CommonResolution::FourK), Seconds(5), Batch(1), ExpectedCredits(103)),
(Some(CommonResolution::FourK), Seconds(5), Batch(2), ExpectedCredits(205)),
(Some(CommonResolution::FourK), Seconds(5), Batch(3), ExpectedCredits(308)),
(Some(CommonResolution::FourK), Seconds(5), Batch(4), ExpectedCredits(410)),
(Some(CommonResolution::FourK), Seconds(5), Batch(5), ExpectedCredits(410)),
(Some(CommonResolution::FourK), Seconds(5), Batch(6), ExpectedCredits(410)),
(Some(CommonResolution::FourK), Seconds(5), Batch(7), ExpectedCredits(410)),
(Some(CommonResolution::FourK), Seconds(5), Batch(8), ExpectedCredits(410)),
(Some(CommonResolution::FourK), Seconds(5), Batch(9), ExpectedCredits(410)),
(Some(CommonResolution::FourK), Seconds(5), Batch(10), ExpectedCredits(410)),
];
for (resolution, seconds, batch, expected) in cases {
@@ -995,36 +1027,52 @@ mod seedance_2p0_bpu_fast {
/// The BytePlus Fast rate card is flat: reference videos never change the price. Charges are asserted on the refunded ledger entry (the fixture media is unreachable).
/// Spot checks across duration x batch x resolution.
/// References must be CHARGED more than the identical no-reference
/// request, at every resolution and across durations.
#[tokio::test]
#[cfg_attr(feature = "skip_database_tests", ignore)]
async fn video_references_charge_more_than_no_references() {
let harness = TestHarness::create().await;
for resolution in [CommonResolution::FourEightyP, CommonResolution::SevenTwentyP] {
for seconds in [5u16, 10, 15] {
assert_references_charge_more(
&harness, CommonVideoModel::Seedance2p0BytePlusUltraFast, Some(resolution), Seconds(seconds),
).await;
}
}
}
#[tokio::test]
#[cfg_attr(feature = "skip_database_tests", ignore)]
async fn video_references_charge_spot_checked_combinations() {
let harness = TestHarness::create().await;
let cases: &[(Option<CommonResolution>, Seconds, Batch, ExpectedCredits)] = &[
(Some(CommonResolution::FourEightyP), Seconds(6), Batch(2), ExpectedCredits(108)),
(Some(CommonResolution::FourEightyP), Seconds(7), Batch(3), ExpectedCredits(189)),
(Some(CommonResolution::FourEightyP), Seconds(9), Batch(4), ExpectedCredits(324)),
(Some(CommonResolution::FourEightyP), Seconds(11), Batch(5), ExpectedCredits(396)),
(Some(CommonResolution::FourEightyP), Seconds(13), Batch(8), ExpectedCredits(468)),
(Some(CommonResolution::FourEightyP), Seconds(15), Batch(10), ExpectedCredits(540)),
(Some(CommonResolution::SevenTwentyP), Seconds(6), Batch(2), ExpectedCredits(240)),
(Some(CommonResolution::SevenTwentyP), Seconds(7), Batch(3), ExpectedCredits(420)),
(Some(CommonResolution::SevenTwentyP), Seconds(9), Batch(4), ExpectedCredits(720)),
(Some(CommonResolution::SevenTwentyP), Seconds(11), Batch(5), ExpectedCredits(880)),
(Some(CommonResolution::SevenTwentyP), Seconds(13), Batch(8), ExpectedCredits(1040)),
(Some(CommonResolution::SevenTwentyP), Seconds(15), Batch(10), ExpectedCredits(1200)),
(Some(CommonResolution::TenEightyP), Seconds(6), Batch(2), ExpectedCredits(240)),
(Some(CommonResolution::TenEightyP), Seconds(7), Batch(3), ExpectedCredits(420)),
(Some(CommonResolution::TenEightyP), Seconds(9), Batch(4), ExpectedCredits(720)),
(Some(CommonResolution::TenEightyP), Seconds(11), Batch(5), ExpectedCredits(880)),
(Some(CommonResolution::TenEightyP), Seconds(13), Batch(8), ExpectedCredits(1040)),
(Some(CommonResolution::TenEightyP), Seconds(15), Batch(10), ExpectedCredits(1200)),
(Some(CommonResolution::FourK), Seconds(6), Batch(2), ExpectedCredits(240)),
(Some(CommonResolution::FourK), Seconds(7), Batch(3), ExpectedCredits(420)),
(Some(CommonResolution::FourK), Seconds(9), Batch(4), ExpectedCredits(720)),
(Some(CommonResolution::FourK), Seconds(11), Batch(5), ExpectedCredits(880)),
(Some(CommonResolution::FourK), Seconds(13), Batch(8), ExpectedCredits(1040)),
(Some(CommonResolution::FourK), Seconds(15), Batch(10), ExpectedCredits(1200)),
(Some(CommonResolution::FourEightyP), Seconds(6), Batch(2), ExpectedCredits(116)),
(Some(CommonResolution::FourEightyP), Seconds(7), Batch(3), ExpectedCredits(203)),
(Some(CommonResolution::FourEightyP), Seconds(9), Batch(4), ExpectedCredits(348)),
(Some(CommonResolution::FourEightyP), Seconds(11), Batch(5), ExpectedCredits(425)),
(Some(CommonResolution::FourEightyP), Seconds(13), Batch(8), ExpectedCredits(502)),
(Some(CommonResolution::FourEightyP), Seconds(15), Batch(10), ExpectedCredits(579)),
(Some(CommonResolution::SevenTwentyP), Seconds(6), Batch(2), ExpectedCredits(246)),
(Some(CommonResolution::SevenTwentyP), Seconds(7), Batch(3), ExpectedCredits(431)),
(Some(CommonResolution::SevenTwentyP), Seconds(9), Batch(4), ExpectedCredits(738)),
(Some(CommonResolution::SevenTwentyP), Seconds(11), Batch(5), ExpectedCredits(902)),
(Some(CommonResolution::SevenTwentyP), Seconds(13), Batch(8), ExpectedCredits(1066)),
(Some(CommonResolution::SevenTwentyP), Seconds(15), Batch(10), ExpectedCredits(1230)),
(Some(CommonResolution::TenEightyP), Seconds(6), Batch(2), ExpectedCredits(246)),
(Some(CommonResolution::TenEightyP), Seconds(7), Batch(3), ExpectedCredits(431)),
(Some(CommonResolution::TenEightyP), Seconds(9), Batch(4), ExpectedCredits(738)),
(Some(CommonResolution::TenEightyP), Seconds(11), Batch(5), ExpectedCredits(902)),
(Some(CommonResolution::TenEightyP), Seconds(13), Batch(8), ExpectedCredits(1066)),
(Some(CommonResolution::TenEightyP), Seconds(15), Batch(10), ExpectedCredits(1230)),
(Some(CommonResolution::FourK), Seconds(6), Batch(2), ExpectedCredits(246)),
(Some(CommonResolution::FourK), Seconds(7), Batch(3), ExpectedCredits(431)),
(Some(CommonResolution::FourK), Seconds(9), Batch(4), ExpectedCredits(738)),
(Some(CommonResolution::FourK), Seconds(11), Batch(5), ExpectedCredits(902)),
(Some(CommonResolution::FourK), Seconds(13), Batch(8), ExpectedCredits(1066)),
(Some(CommonResolution::FourK), Seconds(15), Batch(10), ExpectedCredits(1230)),
];
for (resolution, seconds, batch, expected) in cases {
@@ -18,7 +18,7 @@ use enums::common::generation::common_resolution::CommonResolution;
use enums::common::generation::common_video_model::CommonVideoModel;
use crate::http_server::endpoints::omni_gen::generate::video::tests::support::{
assert_reference_video_charge_then_refund, assert_successful_generation_charges,
assert_reference_video_charge_then_refund, assert_references_charge_more, assert_successful_generation_charges,
assert_variant_charges_premium, Batch, CreditsDelta, ExpectedCredits, Seconds, TestHarness,
};
@@ -314,6 +314,22 @@ mod seedance_2p0_mini {
/// With video references Mini adds its per-second surcharge before the single ceil-rounding. Charges are asserted on the refunded ledger entry (the fixture media is unreachable).
/// Spot checks across duration x batch x resolution.
/// References must be CHARGED more than the identical no-reference
/// request, at every resolution and across durations.
#[tokio::test]
#[cfg_attr(feature = "skip_database_tests", ignore)]
async fn video_references_charge_more_than_no_references() {
let harness = TestHarness::create().await;
for resolution in [CommonResolution::FourEightyP, CommonResolution::SevenTwentyP] {
for seconds in [5u16, 10, 15] {
assert_references_charge_more(
&harness, CommonVideoModel::Seedance2p0Mini, Some(resolution), Seconds(seconds),
).await;
}
}
}
#[tokio::test]
#[cfg_attr(feature = "skip_database_tests", ignore)]
async fn video_references_charge_spot_checked_combinations() {
@@ -649,6 +665,22 @@ mod seedance_2p0_bp_mini {
/// With video references Mini adds its per-second surcharge before the single ceil-rounding. Charges are asserted on the refunded ledger entry (the fixture media is unreachable).
/// Spot checks across duration x batch x resolution.
/// References must be CHARGED more than the identical no-reference
/// request, at every resolution and across durations.
#[tokio::test]
#[cfg_attr(feature = "skip_database_tests", ignore)]
async fn video_references_charge_more_than_no_references() {
let harness = TestHarness::create().await;
for resolution in [CommonResolution::FourEightyP, CommonResolution::SevenTwentyP] {
for seconds in [5u16, 10, 15] {
assert_references_charge_more(
&harness, CommonVideoModel::Seedance2p0BytePlusMini, Some(resolution), Seconds(seconds),
).await;
}
}
}
#[tokio::test]
#[cfg_attr(feature = "skip_database_tests", ignore)]
async fn video_references_charge_spot_checked_combinations() {
@@ -982,6 +1014,22 @@ mod seedance_2p0_bpu_mini {
/// With video references Mini adds its per-second surcharge before the single ceil-rounding. Charges are asserted on the refunded ledger entry (the fixture media is unreachable).
/// Spot checks across duration x batch x resolution.
/// References must be CHARGED more than the identical no-reference
/// request, at every resolution and across durations.
#[tokio::test]
#[cfg_attr(feature = "skip_database_tests", ignore)]
async fn video_references_charge_more_than_no_references() {
let harness = TestHarness::create().await;
for resolution in [CommonResolution::FourEightyP, CommonResolution::SevenTwentyP] {
for seconds in [5u16, 10, 15] {
assert_references_charge_more(
&harness, CommonVideoModel::Seedance2p0BytePlusUltraMini, Some(resolution), Seconds(seconds),
).await;
}
}
}
#[tokio::test]
#[cfg_attr(feature = "skip_database_tests", ignore)]
async fn video_references_charge_spot_checked_combinations() {
@@ -16,7 +16,7 @@ use enums::common::generation::common_resolution::CommonResolution;
use enums::common::generation::common_video_model::CommonVideoModel;
use crate::http_server::endpoints::omni_gen::generate::video::tests::support::{
assert_generation_fails_and_charges_nothing, assert_reference_video_charge_then_refund,
assert_generation_fails_and_charges_nothing, assert_reference_video_charge_then_refund, assert_references_charge_more,
assert_successful_generation_charges, assert_variant_charges_premium, base_generate_request,
Batch, CreditsDelta, ExpectedCredits, Seconds, TestHarness,
};
@@ -313,6 +313,22 @@ mod seedance_2p0 {
/// With video references Seedance 2.0 switches to its with-references rate card (480p 8.81, 720p 22.05, 1080p 51.10, 4K 113.80 cents/s, ceil-rounded). The unreachable fixture media fails the upload after billing, so the exact charge is asserted on the refunded ledger entry.
/// Spot checks across duration x batch x resolution.
/// References must be CHARGED more than the identical no-reference
/// request, at every resolution and across durations.
#[tokio::test]
#[cfg_attr(feature = "skip_database_tests", ignore)]
async fn video_references_charge_more_than_no_references() {
let harness = TestHarness::create().await;
for resolution in [CommonResolution::FourEightyP, CommonResolution::SevenTwentyP, CommonResolution::TenEightyP, CommonResolution::FourK] {
for seconds in [5u16, 10, 15] {
assert_references_charge_more(
&harness, CommonVideoModel::Seedance2p0, Some(resolution), Seconds(seconds),
).await;
}
}
}
#[tokio::test]
#[cfg_attr(feature = "skip_database_tests", ignore)]
async fn video_references_charge_spot_checked_combinations() {
@@ -552,54 +568,54 @@ mod seedance_2p0_bp {
let harness = TestHarness::create().await;
let cases: &[(Option<CommonResolution>, Seconds, Batch, ExpectedCredits)] = &[
(Some(CommonResolution::FourEightyP), Seconds(4), Batch(1), ExpectedCredits(40)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(1), ExpectedCredits(50)),
(Some(CommonResolution::FourEightyP), Seconds(6), Batch(1), ExpectedCredits(60)),
(Some(CommonResolution::FourEightyP), Seconds(7), Batch(1), ExpectedCredits(70)),
(Some(CommonResolution::FourEightyP), Seconds(8), Batch(1), ExpectedCredits(80)),
(Some(CommonResolution::FourEightyP), Seconds(9), Batch(1), ExpectedCredits(90)),
(Some(CommonResolution::FourEightyP), Seconds(10), Batch(1), ExpectedCredits(100)),
(Some(CommonResolution::FourEightyP), Seconds(11), Batch(1), ExpectedCredits(110)),
(Some(CommonResolution::FourEightyP), Seconds(12), Batch(1), ExpectedCredits(120)),
(Some(CommonResolution::FourEightyP), Seconds(13), Batch(1), ExpectedCredits(130)),
(Some(CommonResolution::FourEightyP), Seconds(14), Batch(1), ExpectedCredits(140)),
(Some(CommonResolution::FourEightyP), Seconds(15), Batch(1), ExpectedCredits(150)),
(Some(CommonResolution::SevenTwentyP), Seconds(4), Batch(1), ExpectedCredits(100)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(1), ExpectedCredits(125)),
(Some(CommonResolution::SevenTwentyP), Seconds(6), Batch(1), ExpectedCredits(150)),
(Some(CommonResolution::SevenTwentyP), Seconds(7), Batch(1), ExpectedCredits(175)),
(Some(CommonResolution::SevenTwentyP), Seconds(8), Batch(1), ExpectedCredits(200)),
(Some(CommonResolution::SevenTwentyP), Seconds(9), Batch(1), ExpectedCredits(225)),
(Some(CommonResolution::SevenTwentyP), Seconds(10), Batch(1), ExpectedCredits(250)),
(Some(CommonResolution::SevenTwentyP), Seconds(11), Batch(1), ExpectedCredits(275)),
(Some(CommonResolution::SevenTwentyP), Seconds(12), Batch(1), ExpectedCredits(300)),
(Some(CommonResolution::SevenTwentyP), Seconds(13), Batch(1), ExpectedCredits(325)),
(Some(CommonResolution::SevenTwentyP), Seconds(14), Batch(1), ExpectedCredits(350)),
(Some(CommonResolution::SevenTwentyP), Seconds(15), Batch(1), ExpectedCredits(375)),
(Some(CommonResolution::TenEightyP), Seconds(4), Batch(1), ExpectedCredits(200)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(1), ExpectedCredits(250)),
(Some(CommonResolution::TenEightyP), Seconds(6), Batch(1), ExpectedCredits(300)),
(Some(CommonResolution::TenEightyP), Seconds(7), Batch(1), ExpectedCredits(350)),
(Some(CommonResolution::TenEightyP), Seconds(8), Batch(1), ExpectedCredits(400)),
(Some(CommonResolution::TenEightyP), Seconds(9), Batch(1), ExpectedCredits(450)),
(Some(CommonResolution::TenEightyP), Seconds(10), Batch(1), ExpectedCredits(500)),
(Some(CommonResolution::TenEightyP), Seconds(11), Batch(1), ExpectedCredits(550)),
(Some(CommonResolution::TenEightyP), Seconds(12), Batch(1), ExpectedCredits(600)),
(Some(CommonResolution::TenEightyP), Seconds(13), Batch(1), ExpectedCredits(650)),
(Some(CommonResolution::TenEightyP), Seconds(14), Batch(1), ExpectedCredits(700)),
(Some(CommonResolution::TenEightyP), Seconds(15), Batch(1), ExpectedCredits(750)),
(Some(CommonResolution::FourK), Seconds(4), Batch(1), ExpectedCredits(416)),
(Some(CommonResolution::FourK), Seconds(5), Batch(1), ExpectedCredits(519)),
(Some(CommonResolution::FourK), Seconds(6), Batch(1), ExpectedCredits(623)),
(Some(CommonResolution::FourK), Seconds(7), Batch(1), ExpectedCredits(727)),
(Some(CommonResolution::FourK), Seconds(8), Batch(1), ExpectedCredits(831)),
(Some(CommonResolution::FourK), Seconds(9), Batch(1), ExpectedCredits(935)),
(Some(CommonResolution::FourK), Seconds(10), Batch(1), ExpectedCredits(1038)),
(Some(CommonResolution::FourK), Seconds(11), Batch(1), ExpectedCredits(1142)),
(Some(CommonResolution::FourK), Seconds(12), Batch(1), ExpectedCredits(1246)),
(Some(CommonResolution::FourK), Seconds(13), Batch(1), ExpectedCredits(1350)),
(Some(CommonResolution::FourK), Seconds(14), Batch(1), ExpectedCredits(1454)),
(Some(CommonResolution::FourK), Seconds(15), Batch(1), ExpectedCredits(1557)),
(Some(CommonResolution::FourEightyP), Seconds(4), Batch(1), ExpectedCredits(41)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(1), ExpectedCredits(51)),
(Some(CommonResolution::FourEightyP), Seconds(6), Batch(1), ExpectedCredits(62)),
(Some(CommonResolution::FourEightyP), Seconds(7), Batch(1), ExpectedCredits(72)),
(Some(CommonResolution::FourEightyP), Seconds(8), Batch(1), ExpectedCredits(82)),
(Some(CommonResolution::FourEightyP), Seconds(9), Batch(1), ExpectedCredits(92)),
(Some(CommonResolution::FourEightyP), Seconds(10), Batch(1), ExpectedCredits(102)),
(Some(CommonResolution::FourEightyP), Seconds(11), Batch(1), ExpectedCredits(113)),
(Some(CommonResolution::FourEightyP), Seconds(12), Batch(1), ExpectedCredits(123)),
(Some(CommonResolution::FourEightyP), Seconds(13), Batch(1), ExpectedCredits(133)),
(Some(CommonResolution::FourEightyP), Seconds(14), Batch(1), ExpectedCredits(143)),
(Some(CommonResolution::FourEightyP), Seconds(15), Batch(1), ExpectedCredits(153)),
(Some(CommonResolution::SevenTwentyP), Seconds(4), Batch(1), ExpectedCredits(103)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(1), ExpectedCredits(129)),
(Some(CommonResolution::SevenTwentyP), Seconds(6), Batch(1), ExpectedCredits(155)),
(Some(CommonResolution::SevenTwentyP), Seconds(7), Batch(1), ExpectedCredits(180)),
(Some(CommonResolution::SevenTwentyP), Seconds(8), Batch(1), ExpectedCredits(206)),
(Some(CommonResolution::SevenTwentyP), Seconds(9), Batch(1), ExpectedCredits(232)),
(Some(CommonResolution::SevenTwentyP), Seconds(10), Batch(1), ExpectedCredits(257)),
(Some(CommonResolution::SevenTwentyP), Seconds(11), Batch(1), ExpectedCredits(283)),
(Some(CommonResolution::SevenTwentyP), Seconds(12), Batch(1), ExpectedCredits(309)),
(Some(CommonResolution::SevenTwentyP), Seconds(13), Batch(1), ExpectedCredits(335)),
(Some(CommonResolution::SevenTwentyP), Seconds(14), Batch(1), ExpectedCredits(360)),
(Some(CommonResolution::SevenTwentyP), Seconds(15), Batch(1), ExpectedCredits(386)),
(Some(CommonResolution::TenEightyP), Seconds(4), Batch(1), ExpectedCredits(232)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(1), ExpectedCredits(289)),
(Some(CommonResolution::TenEightyP), Seconds(6), Batch(1), ExpectedCredits(347)),
(Some(CommonResolution::TenEightyP), Seconds(7), Batch(1), ExpectedCredits(405)),
(Some(CommonResolution::TenEightyP), Seconds(8), Batch(1), ExpectedCredits(463)),
(Some(CommonResolution::TenEightyP), Seconds(9), Batch(1), ExpectedCredits(521)),
(Some(CommonResolution::TenEightyP), Seconds(10), Batch(1), ExpectedCredits(578)),
(Some(CommonResolution::TenEightyP), Seconds(11), Batch(1), ExpectedCredits(636)),
(Some(CommonResolution::TenEightyP), Seconds(12), Batch(1), ExpectedCredits(694)),
(Some(CommonResolution::TenEightyP), Seconds(13), Batch(1), ExpectedCredits(752)),
(Some(CommonResolution::TenEightyP), Seconds(14), Batch(1), ExpectedCredits(810)),
(Some(CommonResolution::TenEightyP), Seconds(15), Batch(1), ExpectedCredits(867)),
(Some(CommonResolution::FourK), Seconds(4), Batch(1), ExpectedCredits(456)),
(Some(CommonResolution::FourK), Seconds(5), Batch(1), ExpectedCredits(569)),
(Some(CommonResolution::FourK), Seconds(6), Batch(1), ExpectedCredits(683)),
(Some(CommonResolution::FourK), Seconds(7), Batch(1), ExpectedCredits(797)),
(Some(CommonResolution::FourK), Seconds(8), Batch(1), ExpectedCredits(911)),
(Some(CommonResolution::FourK), Seconds(9), Batch(1), ExpectedCredits(1025)),
(Some(CommonResolution::FourK), Seconds(10), Batch(1), ExpectedCredits(1138)),
(Some(CommonResolution::FourK), Seconds(11), Batch(1), ExpectedCredits(1252)),
(Some(CommonResolution::FourK), Seconds(12), Batch(1), ExpectedCredits(1366)),
(Some(CommonResolution::FourK), Seconds(13), Batch(1), ExpectedCredits(1480)),
(Some(CommonResolution::FourK), Seconds(14), Batch(1), ExpectedCredits(1594)),
(Some(CommonResolution::FourK), Seconds(15), Batch(1), ExpectedCredits(1707)),
];
for (resolution, seconds, batch, expected) in cases {
@@ -618,46 +634,46 @@ mod seedance_2p0_bp {
let harness = TestHarness::create().await;
let cases: &[(Option<CommonResolution>, Seconds, Batch, ExpectedCredits)] = &[
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(1), ExpectedCredits(50)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(2), ExpectedCredits(100)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(3), ExpectedCredits(150)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(4), ExpectedCredits(200)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(5), ExpectedCredits(200)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(6), ExpectedCredits(200)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(7), ExpectedCredits(200)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(8), ExpectedCredits(200)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(9), ExpectedCredits(200)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(10), ExpectedCredits(200)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(1), ExpectedCredits(125)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(2), ExpectedCredits(250)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(3), ExpectedCredits(375)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(4), ExpectedCredits(500)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(5), ExpectedCredits(500)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(6), ExpectedCredits(500)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(7), ExpectedCredits(500)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(8), ExpectedCredits(500)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(9), ExpectedCredits(500)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(10), ExpectedCredits(500)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(1), ExpectedCredits(250)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(2), ExpectedCredits(500)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(3), ExpectedCredits(750)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(4), ExpectedCredits(1000)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(5), ExpectedCredits(1000)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(6), ExpectedCredits(1000)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(7), ExpectedCredits(1000)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(8), ExpectedCredits(1000)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(9), ExpectedCredits(1000)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(10), ExpectedCredits(1000)),
(Some(CommonResolution::FourK), Seconds(5), Batch(1), ExpectedCredits(519)),
(Some(CommonResolution::FourK), Seconds(5), Batch(2), ExpectedCredits(1038)),
(Some(CommonResolution::FourK), Seconds(5), Batch(3), ExpectedCredits(1557)),
(Some(CommonResolution::FourK), Seconds(5), Batch(4), ExpectedCredits(2076)),
(Some(CommonResolution::FourK), Seconds(5), Batch(5), ExpectedCredits(2076)),
(Some(CommonResolution::FourK), Seconds(5), Batch(6), ExpectedCredits(2076)),
(Some(CommonResolution::FourK), Seconds(5), Batch(7), ExpectedCredits(2076)),
(Some(CommonResolution::FourK), Seconds(5), Batch(8), ExpectedCredits(2076)),
(Some(CommonResolution::FourK), Seconds(5), Batch(9), ExpectedCredits(2076)),
(Some(CommonResolution::FourK), Seconds(5), Batch(10), ExpectedCredits(2076)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(1), ExpectedCredits(51)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(2), ExpectedCredits(102)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(3), ExpectedCredits(153)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(4), ExpectedCredits(204)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(5), ExpectedCredits(204)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(6), ExpectedCredits(204)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(7), ExpectedCredits(204)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(8), ExpectedCredits(204)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(9), ExpectedCredits(204)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(10), ExpectedCredits(204)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(1), ExpectedCredits(129)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(2), ExpectedCredits(257)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(3), ExpectedCredits(386)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(4), ExpectedCredits(514)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(5), ExpectedCredits(514)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(6), ExpectedCredits(514)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(7), ExpectedCredits(514)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(8), ExpectedCredits(514)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(9), ExpectedCredits(514)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(10), ExpectedCredits(514)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(1), ExpectedCredits(289)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(2), ExpectedCredits(578)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(3), ExpectedCredits(867)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(4), ExpectedCredits(1156)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(5), ExpectedCredits(1156)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(6), ExpectedCredits(1156)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(7), ExpectedCredits(1156)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(8), ExpectedCredits(1156)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(9), ExpectedCredits(1156)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(10), ExpectedCredits(1156)),
(Some(CommonResolution::FourK), Seconds(5), Batch(1), ExpectedCredits(569)),
(Some(CommonResolution::FourK), Seconds(5), Batch(2), ExpectedCredits(1138)),
(Some(CommonResolution::FourK), Seconds(5), Batch(3), ExpectedCredits(1707)),
(Some(CommonResolution::FourK), Seconds(5), Batch(4), ExpectedCredits(2276)),
(Some(CommonResolution::FourK), Seconds(5), Batch(5), ExpectedCredits(2276)),
(Some(CommonResolution::FourK), Seconds(5), Batch(6), ExpectedCredits(2276)),
(Some(CommonResolution::FourK), Seconds(5), Batch(7), ExpectedCredits(2276)),
(Some(CommonResolution::FourK), Seconds(5), Batch(8), ExpectedCredits(2276)),
(Some(CommonResolution::FourK), Seconds(5), Batch(9), ExpectedCredits(2276)),
(Some(CommonResolution::FourK), Seconds(5), Batch(10), ExpectedCredits(2276)),
];
for (resolution, seconds, batch, expected) in cases {
@@ -669,36 +685,52 @@ mod seedance_2p0_bp {
/// The BytePlus rate cards are flat below 4K: reference videos only change the 4K price (a 17.20 cents/s surcharge). Charges are asserted on the refunded ledger entry (the fixture media is unreachable).
/// Spot checks across duration x batch x resolution.
/// References must be CHARGED more than the identical no-reference
/// request, at every resolution and across durations.
#[tokio::test]
#[cfg_attr(feature = "skip_database_tests", ignore)]
async fn video_references_charge_more_than_no_references() {
let harness = TestHarness::create().await;
for resolution in [CommonResolution::FourEightyP, CommonResolution::SevenTwentyP, CommonResolution::TenEightyP, CommonResolution::FourK] {
for seconds in [5u16, 10, 15] {
assert_references_charge_more(
&harness, CommonVideoModel::Seedance2p0BytePlus, Some(resolution), Seconds(seconds),
).await;
}
}
}
#[tokio::test]
#[cfg_attr(feature = "skip_database_tests", ignore)]
async fn video_references_charge_spot_checked_combinations() {
let harness = TestHarness::create().await;
let cases: &[(Option<CommonResolution>, Seconds, Batch, ExpectedCredits)] = &[
(Some(CommonResolution::FourEightyP), Seconds(6), Batch(2), ExpectedCredits(120)),
(Some(CommonResolution::FourEightyP), Seconds(7), Batch(3), ExpectedCredits(210)),
(Some(CommonResolution::FourEightyP), Seconds(9), Batch(4), ExpectedCredits(360)),
(Some(CommonResolution::FourEightyP), Seconds(11), Batch(5), ExpectedCredits(440)),
(Some(CommonResolution::FourEightyP), Seconds(13), Batch(8), ExpectedCredits(520)),
(Some(CommonResolution::FourEightyP), Seconds(15), Batch(10), ExpectedCredits(600)),
(Some(CommonResolution::SevenTwentyP), Seconds(6), Batch(2), ExpectedCredits(300)),
(Some(CommonResolution::SevenTwentyP), Seconds(7), Batch(3), ExpectedCredits(525)),
(Some(CommonResolution::SevenTwentyP), Seconds(9), Batch(4), ExpectedCredits(900)),
(Some(CommonResolution::SevenTwentyP), Seconds(11), Batch(5), ExpectedCredits(1100)),
(Some(CommonResolution::SevenTwentyP), Seconds(13), Batch(8), ExpectedCredits(1300)),
(Some(CommonResolution::SevenTwentyP), Seconds(15), Batch(10), ExpectedCredits(1500)),
(Some(CommonResolution::TenEightyP), Seconds(6), Batch(2), ExpectedCredits(600)),
(Some(CommonResolution::TenEightyP), Seconds(7), Batch(3), ExpectedCredits(1050)),
(Some(CommonResolution::TenEightyP), Seconds(9), Batch(4), ExpectedCredits(1800)),
(Some(CommonResolution::TenEightyP), Seconds(11), Batch(5), ExpectedCredits(2200)),
(Some(CommonResolution::TenEightyP), Seconds(13), Batch(8), ExpectedCredits(2600)),
(Some(CommonResolution::TenEightyP), Seconds(15), Batch(10), ExpectedCredits(3000)),
(Some(CommonResolution::FourK), Seconds(6), Batch(2), ExpectedCredits(1246)),
(Some(CommonResolution::FourK), Seconds(7), Batch(3), ExpectedCredits(2180)),
(Some(CommonResolution::FourK), Seconds(9), Batch(4), ExpectedCredits(3737)),
(Some(CommonResolution::FourK), Seconds(11), Batch(5), ExpectedCredits(4568)),
(Some(CommonResolution::FourK), Seconds(13), Batch(8), ExpectedCredits(5398)),
(Some(CommonResolution::FourK), Seconds(15), Batch(10), ExpectedCredits(6228)),
(Some(CommonResolution::FourEightyP), Seconds(6), Batch(2), ExpectedCredits(123)),
(Some(CommonResolution::FourEightyP), Seconds(7), Batch(3), ExpectedCredits(215)),
(Some(CommonResolution::FourEightyP), Seconds(9), Batch(4), ExpectedCredits(368)),
(Some(CommonResolution::FourEightyP), Seconds(11), Batch(5), ExpectedCredits(449)),
(Some(CommonResolution::FourEightyP), Seconds(13), Batch(8), ExpectedCredits(531)),
(Some(CommonResolution::FourEightyP), Seconds(15), Batch(10), ExpectedCredits(612)),
(Some(CommonResolution::SevenTwentyP), Seconds(6), Batch(2), ExpectedCredits(309)),
(Some(CommonResolution::SevenTwentyP), Seconds(7), Batch(3), ExpectedCredits(540)),
(Some(CommonResolution::SevenTwentyP), Seconds(9), Batch(4), ExpectedCredits(926)),
(Some(CommonResolution::SevenTwentyP), Seconds(11), Batch(5), ExpectedCredits(1131)),
(Some(CommonResolution::SevenTwentyP), Seconds(13), Batch(8), ExpectedCredits(1337)),
(Some(CommonResolution::SevenTwentyP), Seconds(15), Batch(10), ExpectedCredits(1542)),
(Some(CommonResolution::TenEightyP), Seconds(6), Batch(2), ExpectedCredits(694)),
(Some(CommonResolution::TenEightyP), Seconds(7), Batch(3), ExpectedCredits(1214)),
(Some(CommonResolution::TenEightyP), Seconds(9), Batch(4), ExpectedCredits(2081)),
(Some(CommonResolution::TenEightyP), Seconds(11), Batch(5), ExpectedCredits(2544)),
(Some(CommonResolution::TenEightyP), Seconds(13), Batch(8), ExpectedCredits(3006)),
(Some(CommonResolution::TenEightyP), Seconds(15), Batch(10), ExpectedCredits(3468)),
(Some(CommonResolution::FourK), Seconds(6), Batch(2), ExpectedCredits(1366)),
(Some(CommonResolution::FourK), Seconds(7), Batch(3), ExpectedCredits(2390)),
(Some(CommonResolution::FourK), Seconds(9), Batch(4), ExpectedCredits(4097)),
(Some(CommonResolution::FourK), Seconds(11), Batch(5), ExpectedCredits(5008)),
(Some(CommonResolution::FourK), Seconds(13), Batch(8), ExpectedCredits(5918)),
(Some(CommonResolution::FourK), Seconds(15), Batch(10), ExpectedCredits(6828)),
];
for (resolution, seconds, batch, expected) in cases {
@@ -901,54 +933,54 @@ mod seedance_2p0_bpu {
let harness = TestHarness::create().await;
let cases: &[(Option<CommonResolution>, Seconds, Batch, ExpectedCredits)] = &[
(Some(CommonResolution::FourEightyP), Seconds(4), Batch(1), ExpectedCredits(40)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(1), ExpectedCredits(50)),
(Some(CommonResolution::FourEightyP), Seconds(6), Batch(1), ExpectedCredits(60)),
(Some(CommonResolution::FourEightyP), Seconds(7), Batch(1), ExpectedCredits(70)),
(Some(CommonResolution::FourEightyP), Seconds(8), Batch(1), ExpectedCredits(80)),
(Some(CommonResolution::FourEightyP), Seconds(9), Batch(1), ExpectedCredits(90)),
(Some(CommonResolution::FourEightyP), Seconds(10), Batch(1), ExpectedCredits(100)),
(Some(CommonResolution::FourEightyP), Seconds(11), Batch(1), ExpectedCredits(110)),
(Some(CommonResolution::FourEightyP), Seconds(12), Batch(1), ExpectedCredits(120)),
(Some(CommonResolution::FourEightyP), Seconds(13), Batch(1), ExpectedCredits(130)),
(Some(CommonResolution::FourEightyP), Seconds(14), Batch(1), ExpectedCredits(140)),
(Some(CommonResolution::FourEightyP), Seconds(15), Batch(1), ExpectedCredits(150)),
(Some(CommonResolution::SevenTwentyP), Seconds(4), Batch(1), ExpectedCredits(100)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(1), ExpectedCredits(125)),
(Some(CommonResolution::SevenTwentyP), Seconds(6), Batch(1), ExpectedCredits(150)),
(Some(CommonResolution::SevenTwentyP), Seconds(7), Batch(1), ExpectedCredits(175)),
(Some(CommonResolution::SevenTwentyP), Seconds(8), Batch(1), ExpectedCredits(200)),
(Some(CommonResolution::SevenTwentyP), Seconds(9), Batch(1), ExpectedCredits(225)),
(Some(CommonResolution::SevenTwentyP), Seconds(10), Batch(1), ExpectedCredits(250)),
(Some(CommonResolution::SevenTwentyP), Seconds(11), Batch(1), ExpectedCredits(275)),
(Some(CommonResolution::SevenTwentyP), Seconds(12), Batch(1), ExpectedCredits(300)),
(Some(CommonResolution::SevenTwentyP), Seconds(13), Batch(1), ExpectedCredits(325)),
(Some(CommonResolution::SevenTwentyP), Seconds(14), Batch(1), ExpectedCredits(350)),
(Some(CommonResolution::SevenTwentyP), Seconds(15), Batch(1), ExpectedCredits(375)),
(Some(CommonResolution::TenEightyP), Seconds(4), Batch(1), ExpectedCredits(200)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(1), ExpectedCredits(250)),
(Some(CommonResolution::TenEightyP), Seconds(6), Batch(1), ExpectedCredits(300)),
(Some(CommonResolution::TenEightyP), Seconds(7), Batch(1), ExpectedCredits(350)),
(Some(CommonResolution::TenEightyP), Seconds(8), Batch(1), ExpectedCredits(400)),
(Some(CommonResolution::TenEightyP), Seconds(9), Batch(1), ExpectedCredits(450)),
(Some(CommonResolution::TenEightyP), Seconds(10), Batch(1), ExpectedCredits(500)),
(Some(CommonResolution::TenEightyP), Seconds(11), Batch(1), ExpectedCredits(550)),
(Some(CommonResolution::TenEightyP), Seconds(12), Batch(1), ExpectedCredits(600)),
(Some(CommonResolution::TenEightyP), Seconds(13), Batch(1), ExpectedCredits(650)),
(Some(CommonResolution::TenEightyP), Seconds(14), Batch(1), ExpectedCredits(700)),
(Some(CommonResolution::TenEightyP), Seconds(15), Batch(1), ExpectedCredits(750)),
(Some(CommonResolution::FourK), Seconds(4), Batch(1), ExpectedCredits(416)),
(Some(CommonResolution::FourK), Seconds(5), Batch(1), ExpectedCredits(519)),
(Some(CommonResolution::FourK), Seconds(6), Batch(1), ExpectedCredits(623)),
(Some(CommonResolution::FourK), Seconds(7), Batch(1), ExpectedCredits(727)),
(Some(CommonResolution::FourK), Seconds(8), Batch(1), ExpectedCredits(831)),
(Some(CommonResolution::FourK), Seconds(9), Batch(1), ExpectedCredits(935)),
(Some(CommonResolution::FourK), Seconds(10), Batch(1), ExpectedCredits(1038)),
(Some(CommonResolution::FourK), Seconds(11), Batch(1), ExpectedCredits(1142)),
(Some(CommonResolution::FourK), Seconds(12), Batch(1), ExpectedCredits(1246)),
(Some(CommonResolution::FourK), Seconds(13), Batch(1), ExpectedCredits(1350)),
(Some(CommonResolution::FourK), Seconds(14), Batch(1), ExpectedCredits(1454)),
(Some(CommonResolution::FourK), Seconds(15), Batch(1), ExpectedCredits(1557)),
(Some(CommonResolution::FourEightyP), Seconds(4), Batch(1), ExpectedCredits(41)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(1), ExpectedCredits(51)),
(Some(CommonResolution::FourEightyP), Seconds(6), Batch(1), ExpectedCredits(62)),
(Some(CommonResolution::FourEightyP), Seconds(7), Batch(1), ExpectedCredits(72)),
(Some(CommonResolution::FourEightyP), Seconds(8), Batch(1), ExpectedCredits(82)),
(Some(CommonResolution::FourEightyP), Seconds(9), Batch(1), ExpectedCredits(92)),
(Some(CommonResolution::FourEightyP), Seconds(10), Batch(1), ExpectedCredits(102)),
(Some(CommonResolution::FourEightyP), Seconds(11), Batch(1), ExpectedCredits(113)),
(Some(CommonResolution::FourEightyP), Seconds(12), Batch(1), ExpectedCredits(123)),
(Some(CommonResolution::FourEightyP), Seconds(13), Batch(1), ExpectedCredits(133)),
(Some(CommonResolution::FourEightyP), Seconds(14), Batch(1), ExpectedCredits(143)),
(Some(CommonResolution::FourEightyP), Seconds(15), Batch(1), ExpectedCredits(153)),
(Some(CommonResolution::SevenTwentyP), Seconds(4), Batch(1), ExpectedCredits(103)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(1), ExpectedCredits(129)),
(Some(CommonResolution::SevenTwentyP), Seconds(6), Batch(1), ExpectedCredits(155)),
(Some(CommonResolution::SevenTwentyP), Seconds(7), Batch(1), ExpectedCredits(180)),
(Some(CommonResolution::SevenTwentyP), Seconds(8), Batch(1), ExpectedCredits(206)),
(Some(CommonResolution::SevenTwentyP), Seconds(9), Batch(1), ExpectedCredits(232)),
(Some(CommonResolution::SevenTwentyP), Seconds(10), Batch(1), ExpectedCredits(257)),
(Some(CommonResolution::SevenTwentyP), Seconds(11), Batch(1), ExpectedCredits(283)),
(Some(CommonResolution::SevenTwentyP), Seconds(12), Batch(1), ExpectedCredits(309)),
(Some(CommonResolution::SevenTwentyP), Seconds(13), Batch(1), ExpectedCredits(335)),
(Some(CommonResolution::SevenTwentyP), Seconds(14), Batch(1), ExpectedCredits(360)),
(Some(CommonResolution::SevenTwentyP), Seconds(15), Batch(1), ExpectedCredits(386)),
(Some(CommonResolution::TenEightyP), Seconds(4), Batch(1), ExpectedCredits(232)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(1), ExpectedCredits(289)),
(Some(CommonResolution::TenEightyP), Seconds(6), Batch(1), ExpectedCredits(347)),
(Some(CommonResolution::TenEightyP), Seconds(7), Batch(1), ExpectedCredits(405)),
(Some(CommonResolution::TenEightyP), Seconds(8), Batch(1), ExpectedCredits(463)),
(Some(CommonResolution::TenEightyP), Seconds(9), Batch(1), ExpectedCredits(521)),
(Some(CommonResolution::TenEightyP), Seconds(10), Batch(1), ExpectedCredits(578)),
(Some(CommonResolution::TenEightyP), Seconds(11), Batch(1), ExpectedCredits(636)),
(Some(CommonResolution::TenEightyP), Seconds(12), Batch(1), ExpectedCredits(694)),
(Some(CommonResolution::TenEightyP), Seconds(13), Batch(1), ExpectedCredits(752)),
(Some(CommonResolution::TenEightyP), Seconds(14), Batch(1), ExpectedCredits(810)),
(Some(CommonResolution::TenEightyP), Seconds(15), Batch(1), ExpectedCredits(867)),
(Some(CommonResolution::FourK), Seconds(4), Batch(1), ExpectedCredits(456)),
(Some(CommonResolution::FourK), Seconds(5), Batch(1), ExpectedCredits(569)),
(Some(CommonResolution::FourK), Seconds(6), Batch(1), ExpectedCredits(683)),
(Some(CommonResolution::FourK), Seconds(7), Batch(1), ExpectedCredits(797)),
(Some(CommonResolution::FourK), Seconds(8), Batch(1), ExpectedCredits(911)),
(Some(CommonResolution::FourK), Seconds(9), Batch(1), ExpectedCredits(1025)),
(Some(CommonResolution::FourK), Seconds(10), Batch(1), ExpectedCredits(1138)),
(Some(CommonResolution::FourK), Seconds(11), Batch(1), ExpectedCredits(1252)),
(Some(CommonResolution::FourK), Seconds(12), Batch(1), ExpectedCredits(1366)),
(Some(CommonResolution::FourK), Seconds(13), Batch(1), ExpectedCredits(1480)),
(Some(CommonResolution::FourK), Seconds(14), Batch(1), ExpectedCredits(1594)),
(Some(CommonResolution::FourK), Seconds(15), Batch(1), ExpectedCredits(1707)),
];
for (resolution, seconds, batch, expected) in cases {
@@ -967,46 +999,46 @@ mod seedance_2p0_bpu {
let harness = TestHarness::create().await;
let cases: &[(Option<CommonResolution>, Seconds, Batch, ExpectedCredits)] = &[
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(1), ExpectedCredits(50)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(2), ExpectedCredits(100)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(3), ExpectedCredits(150)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(4), ExpectedCredits(200)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(5), ExpectedCredits(200)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(6), ExpectedCredits(200)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(7), ExpectedCredits(200)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(8), ExpectedCredits(200)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(9), ExpectedCredits(200)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(10), ExpectedCredits(200)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(1), ExpectedCredits(125)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(2), ExpectedCredits(250)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(3), ExpectedCredits(375)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(4), ExpectedCredits(500)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(5), ExpectedCredits(500)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(6), ExpectedCredits(500)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(7), ExpectedCredits(500)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(8), ExpectedCredits(500)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(9), ExpectedCredits(500)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(10), ExpectedCredits(500)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(1), ExpectedCredits(250)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(2), ExpectedCredits(500)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(3), ExpectedCredits(750)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(4), ExpectedCredits(1000)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(5), ExpectedCredits(1000)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(6), ExpectedCredits(1000)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(7), ExpectedCredits(1000)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(8), ExpectedCredits(1000)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(9), ExpectedCredits(1000)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(10), ExpectedCredits(1000)),
(Some(CommonResolution::FourK), Seconds(5), Batch(1), ExpectedCredits(519)),
(Some(CommonResolution::FourK), Seconds(5), Batch(2), ExpectedCredits(1038)),
(Some(CommonResolution::FourK), Seconds(5), Batch(3), ExpectedCredits(1557)),
(Some(CommonResolution::FourK), Seconds(5), Batch(4), ExpectedCredits(2076)),
(Some(CommonResolution::FourK), Seconds(5), Batch(5), ExpectedCredits(2076)),
(Some(CommonResolution::FourK), Seconds(5), Batch(6), ExpectedCredits(2076)),
(Some(CommonResolution::FourK), Seconds(5), Batch(7), ExpectedCredits(2076)),
(Some(CommonResolution::FourK), Seconds(5), Batch(8), ExpectedCredits(2076)),
(Some(CommonResolution::FourK), Seconds(5), Batch(9), ExpectedCredits(2076)),
(Some(CommonResolution::FourK), Seconds(5), Batch(10), ExpectedCredits(2076)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(1), ExpectedCredits(51)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(2), ExpectedCredits(102)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(3), ExpectedCredits(153)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(4), ExpectedCredits(204)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(5), ExpectedCredits(204)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(6), ExpectedCredits(204)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(7), ExpectedCredits(204)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(8), ExpectedCredits(204)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(9), ExpectedCredits(204)),
(Some(CommonResolution::FourEightyP), Seconds(5), Batch(10), ExpectedCredits(204)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(1), ExpectedCredits(129)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(2), ExpectedCredits(257)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(3), ExpectedCredits(386)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(4), ExpectedCredits(514)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(5), ExpectedCredits(514)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(6), ExpectedCredits(514)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(7), ExpectedCredits(514)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(8), ExpectedCredits(514)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(9), ExpectedCredits(514)),
(Some(CommonResolution::SevenTwentyP), Seconds(5), Batch(10), ExpectedCredits(514)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(1), ExpectedCredits(289)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(2), ExpectedCredits(578)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(3), ExpectedCredits(867)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(4), ExpectedCredits(1156)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(5), ExpectedCredits(1156)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(6), ExpectedCredits(1156)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(7), ExpectedCredits(1156)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(8), ExpectedCredits(1156)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(9), ExpectedCredits(1156)),
(Some(CommonResolution::TenEightyP), Seconds(5), Batch(10), ExpectedCredits(1156)),
(Some(CommonResolution::FourK), Seconds(5), Batch(1), ExpectedCredits(569)),
(Some(CommonResolution::FourK), Seconds(5), Batch(2), ExpectedCredits(1138)),
(Some(CommonResolution::FourK), Seconds(5), Batch(3), ExpectedCredits(1707)),
(Some(CommonResolution::FourK), Seconds(5), Batch(4), ExpectedCredits(2276)),
(Some(CommonResolution::FourK), Seconds(5), Batch(5), ExpectedCredits(2276)),
(Some(CommonResolution::FourK), Seconds(5), Batch(6), ExpectedCredits(2276)),
(Some(CommonResolution::FourK), Seconds(5), Batch(7), ExpectedCredits(2276)),
(Some(CommonResolution::FourK), Seconds(5), Batch(8), ExpectedCredits(2276)),
(Some(CommonResolution::FourK), Seconds(5), Batch(9), ExpectedCredits(2276)),
(Some(CommonResolution::FourK), Seconds(5), Batch(10), ExpectedCredits(2276)),
];
for (resolution, seconds, batch, expected) in cases {
@@ -1018,36 +1050,52 @@ mod seedance_2p0_bpu {
/// The BytePlus rate cards are flat below 4K: reference videos only change the 4K price (a 17.20 cents/s surcharge). Charges are asserted on the refunded ledger entry (the fixture media is unreachable).
/// Spot checks across duration x batch x resolution.
/// References must be CHARGED more than the identical no-reference
/// request, at every resolution and across durations.
#[tokio::test]
#[cfg_attr(feature = "skip_database_tests", ignore)]
async fn video_references_charge_more_than_no_references() {
let harness = TestHarness::create().await;
for resolution in [CommonResolution::FourEightyP, CommonResolution::SevenTwentyP, CommonResolution::TenEightyP, CommonResolution::FourK] {
for seconds in [5u16, 10, 15] {
assert_references_charge_more(
&harness, CommonVideoModel::Seedance2p0BytePlusUltra, Some(resolution), Seconds(seconds),
).await;
}
}
}
#[tokio::test]
#[cfg_attr(feature = "skip_database_tests", ignore)]
async fn video_references_charge_spot_checked_combinations() {
let harness = TestHarness::create().await;
let cases: &[(Option<CommonResolution>, Seconds, Batch, ExpectedCredits)] = &[
(Some(CommonResolution::FourEightyP), Seconds(6), Batch(2), ExpectedCredits(120)),
(Some(CommonResolution::FourEightyP), Seconds(7), Batch(3), ExpectedCredits(210)),
(Some(CommonResolution::FourEightyP), Seconds(9), Batch(4), ExpectedCredits(360)),
(Some(CommonResolution::FourEightyP), Seconds(11), Batch(5), ExpectedCredits(440)),
(Some(CommonResolution::FourEightyP), Seconds(13), Batch(8), ExpectedCredits(520)),
(Some(CommonResolution::FourEightyP), Seconds(15), Batch(10), ExpectedCredits(600)),
(Some(CommonResolution::SevenTwentyP), Seconds(6), Batch(2), ExpectedCredits(300)),
(Some(CommonResolution::SevenTwentyP), Seconds(7), Batch(3), ExpectedCredits(525)),
(Some(CommonResolution::SevenTwentyP), Seconds(9), Batch(4), ExpectedCredits(900)),
(Some(CommonResolution::SevenTwentyP), Seconds(11), Batch(5), ExpectedCredits(1100)),
(Some(CommonResolution::SevenTwentyP), Seconds(13), Batch(8), ExpectedCredits(1300)),
(Some(CommonResolution::SevenTwentyP), Seconds(15), Batch(10), ExpectedCredits(1500)),
(Some(CommonResolution::TenEightyP), Seconds(6), Batch(2), ExpectedCredits(600)),
(Some(CommonResolution::TenEightyP), Seconds(7), Batch(3), ExpectedCredits(1050)),
(Some(CommonResolution::TenEightyP), Seconds(9), Batch(4), ExpectedCredits(1800)),
(Some(CommonResolution::TenEightyP), Seconds(11), Batch(5), ExpectedCredits(2200)),
(Some(CommonResolution::TenEightyP), Seconds(13), Batch(8), ExpectedCredits(2600)),
(Some(CommonResolution::TenEightyP), Seconds(15), Batch(10), ExpectedCredits(3000)),
(Some(CommonResolution::FourK), Seconds(6), Batch(2), ExpectedCredits(1246)),
(Some(CommonResolution::FourK), Seconds(7), Batch(3), ExpectedCredits(2180)),
(Some(CommonResolution::FourK), Seconds(9), Batch(4), ExpectedCredits(3737)),
(Some(CommonResolution::FourK), Seconds(11), Batch(5), ExpectedCredits(4568)),
(Some(CommonResolution::FourK), Seconds(13), Batch(8), ExpectedCredits(5398)),
(Some(CommonResolution::FourK), Seconds(15), Batch(10), ExpectedCredits(6228)),
(Some(CommonResolution::FourEightyP), Seconds(6), Batch(2), ExpectedCredits(123)),
(Some(CommonResolution::FourEightyP), Seconds(7), Batch(3), ExpectedCredits(215)),
(Some(CommonResolution::FourEightyP), Seconds(9), Batch(4), ExpectedCredits(368)),
(Some(CommonResolution::FourEightyP), Seconds(11), Batch(5), ExpectedCredits(449)),
(Some(CommonResolution::FourEightyP), Seconds(13), Batch(8), ExpectedCredits(531)),
(Some(CommonResolution::FourEightyP), Seconds(15), Batch(10), ExpectedCredits(612)),
(Some(CommonResolution::SevenTwentyP), Seconds(6), Batch(2), ExpectedCredits(309)),
(Some(CommonResolution::SevenTwentyP), Seconds(7), Batch(3), ExpectedCredits(540)),
(Some(CommonResolution::SevenTwentyP), Seconds(9), Batch(4), ExpectedCredits(926)),
(Some(CommonResolution::SevenTwentyP), Seconds(11), Batch(5), ExpectedCredits(1131)),
(Some(CommonResolution::SevenTwentyP), Seconds(13), Batch(8), ExpectedCredits(1337)),
(Some(CommonResolution::SevenTwentyP), Seconds(15), Batch(10), ExpectedCredits(1542)),
(Some(CommonResolution::TenEightyP), Seconds(6), Batch(2), ExpectedCredits(694)),
(Some(CommonResolution::TenEightyP), Seconds(7), Batch(3), ExpectedCredits(1214)),
(Some(CommonResolution::TenEightyP), Seconds(9), Batch(4), ExpectedCredits(2081)),
(Some(CommonResolution::TenEightyP), Seconds(11), Batch(5), ExpectedCredits(2544)),
(Some(CommonResolution::TenEightyP), Seconds(13), Batch(8), ExpectedCredits(3006)),
(Some(CommonResolution::TenEightyP), Seconds(15), Batch(10), ExpectedCredits(3468)),
(Some(CommonResolution::FourK), Seconds(6), Batch(2), ExpectedCredits(1366)),
(Some(CommonResolution::FourK), Seconds(7), Batch(3), ExpectedCredits(2390)),
(Some(CommonResolution::FourK), Seconds(9), Batch(4), ExpectedCredits(4097)),
(Some(CommonResolution::FourK), Seconds(11), Batch(5), ExpectedCredits(5008)),
(Some(CommonResolution::FourK), Seconds(13), Batch(8), ExpectedCredits(5918)),
(Some(CommonResolution::FourK), Seconds(15), Batch(10), ExpectedCredits(6828)),
];
for (resolution, seconds, batch, expected) in cases {
@@ -4,6 +4,7 @@
//! with dummy Actix HTTP requests as a fixture user.
use std::collections::HashSet;
use std::convert::TryFrom;
use std::marker::PhantomData;
use std::sync::Arc;
use std::time::Duration;
@@ -794,6 +795,58 @@ pub async fn assert_generation_fails_and_charges_nothing(
);
}
/// Run the same generation twice — once without and once with a reference
/// video, as two independent fixture users — and assert the referenced
/// generation is CHARGED strictly more credits. The no-reference generation
/// succeeds outright; the referenced one uses an unreachable fixture (charge
/// then refund), so its charge is read from the ledger debit entry.
pub async fn assert_references_charge_more(
harness: &TestHarness,
model: CommonVideoModel,
resolution: Option<enums::common::generation::common_resolution::CommonResolution>,
Seconds(duration_seconds): Seconds,
) {
let no_ref_user = harness.create_funded_user(STARTING_CREDITS).await;
let mut request = base_generate_request(model);
request.resolution = resolution;
request.duration_seconds = Some(duration_seconds);
let response = harness
.post_generate(&no_ref_user, request)
.await
.unwrap_or_else(|err| {
panic!("{:?} {:?} {}s: no-reference generation failed: {:?}", model, resolution, duration_seconds, err)
});
assert!(response.success);
let no_ref_debit = STARTING_CREDITS - harness.wallet_balance(&no_ref_user).await;
let ref_user = harness.create_funded_user(STARTING_CREDITS).await;
let video_token = mysql_testing::fixtures::media_files::create_test_video_media_file(
&harness.pool,
&ref_user.user_token,
Some(6_000),
)
.await
.expect("create video media file fixture");
let mut request = base_generate_request(model);
request.resolution = resolution;
request.duration_seconds = Some(duration_seconds);
request.reference_video_media_tokens = Some(vec![video_token]);
// The unreachable fixture fails after billing; the charge is in the ledger.
let _ = harness.post_generate(&ref_user, request).await;
let entries = harness.ledger_entries(&ref_user).await;
let ref_debit = entries
.iter()
.find(|entry| entry.credits_delta < 0)
.unwrap_or_else(|| panic!("{:?} {:?} {}s: no ledger debit for referenced generation", model, resolution, duration_seconds));
let ref_debit = u64::try_from(-ref_debit.credits_delta).expect("positive debit");
assert!(
ref_debit > no_ref_debit,
"{:?} {:?} {}s: references must charge more (ref {} vs no-ref {})",
model, resolution, duration_seconds, ref_debit, no_ref_debit,
);
}
/// Assert the variant model charges a premium over the base model: runs one
/// generation on EACH model, asserts both exact charges, and that
/// `variant == base + delta`. (A delta of 0 is allowed where ceil-rounding